[VSDK] Macho PB 1.9.8

Totte Alm totte at code66.se
Mon Oct 6 16:36:22 CDT 2003


lördagen den 4 oktober 2003 kl 10.39 skrev Ruslan Zasukhin:

> Yes.
>
> To try reproduce this hang you need definitely trash .ind file.

OK, this seems to happen about every 10th run, so it a very bad problem.

here is some code so you see what I do. This is where it hangs....
  "<------ IT STALLS RIGHT HERE!!!!!!!!!!!" marks where it stalls, its  
down in MakeFAMOBundle()

// Bundle the famobolag way
void
FamoBundler(BundleInfoPtr bip)
{
	// Locals
	SisDB*				db = bip->mDB;
	VDK_Cursor*		 	mc1=NULL;
	VDK_Cursor*			mc2=NULL;
	UInt32				mc2count;
	FBL_String			*mc1code, *mc2code;
	bool				cangoon=true;
	SInt16				typebit=0;
	
	try {
		mc2 = db->SqlSelect("SELECT recid, HID, Name, bundlename,  
NameChanged, IsGoverner, totalshares, "
							"bundleid, isbundled, isinsider, totalvotes, familyflag  FROM  
HolderTable "
							"WHERE bundlename >'' ORDER BY bundlename ASC, familyflag DESC",  
kClient, kNoLock ,kRandom );
	
		// Do the two selects
		mc1 = db->SqlSelect("SELECT recid, HID, Name, bundlename,  
NameChanged, IsGoverner, totalshares, "
							"bundleid, isbundled, isinsider, totalvotes, familyflag  FROM  
HolderTable "
							"WHERE bundlename >'' ORDER BY bundlename ASC, familyflag DESC",  
kClient, kNoLock ,kRandom );
	
	} catch ( ... ) {
		::SysBeep(1);
	}
	
	// Check if we did get any cursors
	if ( mc1 == NULL || mc2 == NULL ) {
		LOG(TRCB_STD1, "Bundling failed, couldnt load cursorsets");
		return;
	}
	
	// Set macx to go
	bip->maxStages=mc2->GetRecordCount();
	
	// Position both at first position, the step #2 one more
	mc1->FirstRecord();
	mc2->FirstRecord();
	mc2count = mc2->GetRecordCount();
	mc2->NextRecord();
	LOG(TRCB_STD1, "Got %ld records",  mc2count );
	bip->lastBundleRecord = NULL;
	

	// The Big bad (even badder now) Bundleloop
	do {
		LOG(TRCB_STD1, "Taking loop...." );

		// feedback info
		bip->stageCount=mc2->GetPosition();
		CheckForBackCall(bip);
		
		// Some checks
		if ( mc1->GetPosition() >= mc2->GetPosition()  ) {
			LOG(TRCB_STD1, "First >= 2nd (%ld, %ld)", mc1->GetPosition() ,  
mc2->GetPosition() );
			cangoon = mc2->GoToRecord( mc1->GetPosition()+1);
			LOG(TRCB_STD1, "cangoon=%s", (cangoon?"true":"false"));
			if ( cangoon == false ) {
				bip->lastBundleRecord = NULL;
				typebit=0;
				// Make a new Self famobolagbundlerecord
				mc1code = mc1->GetString(4);
				LOG(TRCB_STD1, "LAST '%s' [To Be SELF-FAMO Bundled]", (char*)  
*mc1code );
				MakeSELFFAMOBundle( mc1, bip);
			}
			continue;
		}

		// Get the famos
		mc1code = mc1->GetString(4);
		mc2code = mc2->GetString(4);
		
		// Compare name
		if ( strcmp( (char*) *mc1code, (char*) *mc2code ) != 0 ) {
			if ( bip->lastBundleRecord == NULL ) {
				// Make a new Self famobolagbundlerecord
				LOG(TRCB_STD1, "'%s' [To Be SELF-FAMO Bundled]", (char*) *mc1code );
				MakeSELFFAMOBundle( mc1, bip);
			}
			else {
				LOG(TRCB_STD1, "* Failed * on bundlename" );
			}
			
			// Set to next
			LOG(TRCB_STD1, "Positions now (%ld, %ld)", mc1->GetPosition() ,  
mc2->GetPosition() );
			mc1->GoToRecord(mc2->GetPosition());
			LOG(TRCB_STD1, "[mc1->GoToRecord] Positions now (%ld, %ld)",  
mc1->GetPosition() , mc2->GetPosition() );
			cangoon = mc2->NextRecord();
			LOG(TRCB_STD1, "[mc2->NextRecord] Positions now (%ld, %ld)",  
mc1->GetPosition() , mc2->GetPosition() );
			LOG(TRCB_STD1, "cangoon=%s", (cangoon?"true":"false"));
			bip->lastBundleRecord = NULL;
			typebit=0;
			if ( cangoon == false ) {
				// Make a new Self famobolagbundlerecord
				LOG(TRCB_STD1, "LAST '%s' [To Be SELF-FAMO Bundled]", (char*)  
*mc1code );
				MakeSELFFAMOBundle( mc1, bip);
			}
			continue;
		}
		
		// Make a new famobolagbundlerecord
		LOG(TRCB_STD1, "[To Be FAMO Bundled]" );
		typebit = MakeFAMOBundle( mc1,  mc2, bip, typebit );
		cangoon = mc2->NextRecord();
		LOG(TRCB_STD1, "cangoon=%s", (cangoon?"true":"false"));

	
	} while( mc2->GetPosition() <= mc2count && cangoon==true);

	if ( mc1 ) {
		delete mc1;
	}
	if ( mc2 ) {
		delete mc2;
	}

}

// Make a new Fam-o-Bolag Bundlerecord
SInt16
MakeFAMOBundle(VDK_Cursor* mc1, VDK_Cursor* mc2, BundleInfoPtr bip,  
SInt16 typebit)
{
	// Locals
	UInt32		 		recid;
	SisDB*				db = bip->mDB;
	SInt16				outType=typebit;
	char				famname[64];
	char				dummy[256];
	UInt64				ts;
	double				tv;
		
	// Check if we have a bundlerecord to build on
	if ( bip->lastBundleRecord == NULL ) {
		LOG(TRCB_STD1, "[Bundled] No lastBundleRecord found, new master..." );
		
		// Clone that record
		db->mHolder->GoToRecord(mc1->GetULong(1));

		// Clone that record
		if (!db->mHolder->GoToRecord(mc1->GetULong(1))) {
			LOG(TRCB_STD0, "[Bundled] Record from #1 not found!" );
			return 0;
		}
		
		recid = db->mHolder->AddRecord(); <------ IT STALLS RIGHT  
HERE!!!!!!!!!!!
		bip->lastBundleRecord = recid;
		LOG(TRCB_STD1, "[Bundled] New masterrecord with ID=%ld created.",  
recid );
		
		// Set the bundle flag
		db->mHolder->GoToRecord(recid);
		bip->bundleCounter++;
		db->mHolder->bundleid = bip->bundleCounter;
		LOG(TRCB_STD1, "[Bundled] BundleID=%ld.", bip->bundleCounter);
		db->mHolder->isbundled = 1;
		db->mHolder->isbundlerecord = 1;
		db->mHolder->gender=kSisHolderGenderNone;
		db->mHolder->oldname = "**FAMOBUNDLING**";
		db->mHolder->UpdateRecord();
	

		// What for one are this we dont feel again you?
		LOG(TRCB_STD1, "outType was %d", outType );
		
		switch( mc1->GetShort(12) ) {
			case 1: // klanhuvud
				outType |= bitClan;
				LOG(TRCB_STD1, "added bitClan to outType from firstrecord");
				break;
				
			case 2: // Familj
				outType |= bitFam;
				LOG(TRCB_STD1, "added bitFam to outType from firstrecord");
				break;

			case 3: // Bolag
				outType |= bitBol;
				LOG(TRCB_STD1, "added bitBol to outType from firstrecord");
				break;
		}
		LOG(TRCB_STD1, "outType now set to %d", outType );

		db->mHolder->UpdateRecord();
		
		// Position the first
		*(mc1->GetULongField(8))=bip->bundleCounter;
		*(mc1->GetShortField(9))=1;
		mc1->Update();
		
		// Copy the sharerecords
		LOG(TRCB_STD1, "*ShareCopy called*" );
		ShareCopy( mc1->GetULong(1), recid, bip );
	}
	else {
		recid =  bip->lastBundleRecord;
		LOG(TRCB_STD1, "[Bundled] Masterrecord with ID=%ld reused.", recid );
	}
	
	// Position the second
	*(mc2->GetULongField(8))=bip->bundleCounter;
	*(mc2->GetShortField(9))=1;
	mc2->Update();

	// What for one are this we dont feel again you?
	switch(  mc2->GetShort(12) ) {
		case 1: // klanhuvud
			outType |= bitClan;
			LOG(TRCB_STD1, "added bitClan to outType from secondrecord");
			break;

		case 2: // Familj
			outType |= bitFam;
			LOG(TRCB_STD1, "added bitFam to outType from secondrecord");
			break;

		case 3: // Bolag
			outType |= bitBol;
			LOG(TRCB_STD1, "added bitBol to outType from secondrecord");
			break;
	}
	db->mHolder->UpdateRecord();
	
	// Add shares
	ShareAdd( mc2->GetULong(1), recid, bip );

	// Handle the namestuff
	db->mHolder->GoToRecord(recid);

	// Get clanfathers name
	strcpy( famname, db->mHolder->bundlename );
	LOG(TRCB_STD1, "Get Clanhead for clan '%s'.", famname );
	BUGetClanHeadForClan( bip, famname, 63 );
	
	// What nameextesion needed
	switch( outType ) {
		default:
			break;

		case 1: // Fam.
			strcat(famname, " fam");
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' fam'.", outType);
			break;

		case 2: // Bol.
			if ( strlen(famname) < 22 ) {
				strcat(famname, " bolag");
			}
			else {
				strcat(famname, " bol");
			}
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' bol'.", outType);
			break;

		case 3: // Fam o Bol.
			if ( strlen(famname) < 16 ) {
				strcat(famname, " fam o bolag");
			}
			else {
				strcat(famname, " fam o bol");
			}
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' fam o bol'.",  
outType);
			break;

		case 5: //  o Fam.
			strcat(famname, " o fam");
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' o fam'.",  
outType);
			break;

		case 6: //  o Bol.
			if ( strlen(famname) < 20 ) {
				strcat(famname, " o bolag");
			}
			else {
				strcat(famname, " o bol");
			}
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' o bol'.",  
outType);
			break;

		case 7: // o Fam o Bol.
			if ( strlen(famname) < 16 ) {
				strcat(famname, " fam o bolag");
			}
			else {
				strcat(famname, " fam o bol");
			}
			db->mHolder->newname=famname;
			LOG(TRCB_STD1, "Outtype=%d: fam extension set to ' o fam o bol'.",  
outType);
			break;
	}
	
	LOG(TRCB_STD1, "FAMO Bundlename now set to '%s'.", famname );
	strcpy( dummy, famname);
	UTSmallUtils::MakeLowerCaseFromType(dummy, 63,  
kCFStringEncodingISOLatin1);
	UTSmallUtils::MakeISOToMac(dummy,63);
	bip->mDB->mHolder->sortname = dummy;

	// Move shares
	ts = db->mHolder->totalshares;
	tv = db->mHolder->totalvotes;
	ts += mc2->GetULLong(7);
	tv += mc2->GetDouble(11);
	db->mHolder->totalshares = ts;
	db->mHolder->totalvotes = tv;
	db->mHolder->UpdateRecord();
	
	// Pass it
	return outType;
}

// Totte

>
------------------------------------------------------------------------ 
---------------------
Intelligence is meassured in tary; decitary, centitary and military.


More information about the Valentina mailing list