[Opentnl-cvs] tnl/tnl journal.cpp,1.2,1.3 netInterface.cpp,1.2,1.3 tnlJournal.h,1.2,1.3
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-05-11 18:26:37
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3672/tnl Modified Files: journal.cpp netInterface.cpp tnlJournal.h Log Message: Added size optimizations on journal writes Added flush of journal Added debug break at end of journal playback Index: tnlJournal.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tnlJournal.h 11 May 2004 02:45:26 -0000 1.2 --- tnlJournal.h 11 May 2004 18:26:24 -0000 1.3 *************** *** 77,92 **** struct JournalEntryRecord { const char *mFunctionName; MethodArgList *mMethodArgList; JournalEntryRecord *mNext; ! static JournalEntryRecord *mList; - JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) - { - mFunctionName = functionName; - mMethodArgList = methodArgList; - mNext = mList; - mList = this; - } virtual void getFuncPtr(MethodPointer &m) = 0; }; --- 77,89 ---- struct JournalEntryRecord { + U32 mEntryIndex; const char *mFunctionName; MethodArgList *mMethodArgList; JournalEntryRecord *mNext; ! static Vector<JournalEntryRecord *> *mEntryVector; ! ! JournalEntryRecord(const char *functionName, MethodArgList *methodArgList); ! ~JournalEntryRecord(); virtual void getFuncPtr(MethodPointer &m) = 0; }; Index: journal.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/journal.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** journal.cpp 11 May 2004 02:45:26 -0000 1.2 --- journal.cpp 11 May 2004 18:26:24 -0000 1.3 *************** *** 31,35 **** { ! JournalEntryRecord *JournalEntryRecord::mList = NULL; bool Journal::mInsideEntrypoint = false; --- 31,35 ---- { ! Vector<JournalEntryRecord *> *JournalEntryRecord::mEntryVector; bool Journal::mInsideEntrypoint = false; *************** *** 42,45 **** --- 42,72 ---- U32 Journal::mWritePosition = 0; + JournalEntryRecord::JournalEntryRecord(const char *functionName, MethodArgList *methodArgList) + { + S32 i; + if(!mEntryVector) + mEntryVector = new Vector<JournalEntryRecord *>; + + for(i = 0; i < mEntryVector->size(); i++) + { + if(strcmp((*mEntryVector)[i]->mFunctionName, functionName) < 0) + break; + } + mEntryVector->insert(i); + (*mEntryVector)[i] = this; + mFunctionName = functionName; + mMethodArgList = methodArgList; + mEntryIndex = 0; + } + + JournalEntryRecord::~JournalEntryRecord() + { + if(mEntryVector) + { + delete mEntryVector; + mEntryVector = NULL; + } + } + Journal::Journal() { *************** *** 72,75 **** --- 99,103 ---- // write the bytes to the file fwrite(mWriteStream.getBuffer(), 1, bytesToWrite, mJournalFile); + fflush(mJournalFile); // adjust the write stream *************** *** 124,130 **** TNLAssert(mInsideEntrypoint == false, "Journal entries cannot be reentrant!"); mInsideEntrypoint = true; if(mCurrentMode == Record) { ! mWriteStream.writeString(funcName); mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); syncWriteStream(); --- 152,167 ---- TNLAssert(mInsideEntrypoint == false, "Journal entries cannot be reentrant!"); mInsideEntrypoint = true; + + S32 entryIndex; + for(entryIndex = 0; entryIndex < JournalEntryRecord::mEntryVector->size(); entryIndex++) + { + if(!strcmp((*JournalEntryRecord::mEntryVector)[entryIndex]->mFunctionName, funcName)) + break; + } + TNLAssert(entryIndex != JournalEntryRecord::mEntryVector->size(), "No entry point found!"); + if(mCurrentMode == Record) { ! mWriteStream.writeRangedU32(entryIndex, 0, JournalEntryRecord::mEntryVector->size() - 1); mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer()); syncWriteStream(); *************** *** 133,148 **** BitStream unmarshallData(theCall->marshalledData.getBuffer(), theCall->marshalledData.getBytePosition()); theCall->unmarshall(&unmarshallData); ! for(JournalEntryRecord *walk = JournalEntryRecord::mList; walk; walk = walk->mNext) ! { ! if(!strcmp(walk->mFunctionName, funcName)) ! { ! MethodPointer p; ! walk->getFuncPtr(p); ! theCall->dispatch((void *) this, &p); ! mInsideEntrypoint = false; ! return; ! } ! } ! TNLAssert(0, "No entry point found!"); } --- 170,179 ---- BitStream unmarshallData(theCall->marshalledData.getBuffer(), theCall->marshalledData.getBytePosition()); theCall->unmarshall(&unmarshallData); ! ! JournalEntryRecord *theEntry = (*JournalEntryRecord::mEntryVector)[entryIndex]; ! MethodPointer p; ! theEntry->getFuncPtr(p); ! theCall->dispatch((void *) this, &p); ! mInsideEntrypoint = false; } *************** *** 150,154 **** { if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) ! Platform::debugBreak(); } --- 181,185 ---- { if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition()) ! TNL_DEBUGBREAK(); } *************** *** 158,167 **** return; ! char funcName[256]; ! mReadStream.readString(funcName); ! JournalEntryRecord *theEntry; ! for(theEntry = JournalEntryRecord::mList; theEntry; theEntry = theEntry->mNext) ! if(!strcmp(theEntry->mFunctionName, funcName)) ! break; // check for errors... --- 189,195 ---- return; ! U32 index = mReadStream.readRangedU32(0, JournalEntryRecord::mEntryVector->size()); ! ! JournalEntryRecord *theEntry = (*JournalEntryRecord::mEntryVector)[index]; // check for errors... *************** *** 170,174 **** TNLAssert(0, "blech!"); } - checkReadPosition(); MethodPointer p; --- 198,201 ---- *************** *** 176,179 **** --- 203,208 ---- MarshalledCall theCall(theEntry->mMethodArgList); theCall.unmarshall(&mReadStream); + checkReadPosition(); + mInsideEntrypoint = true; theCall.dispatch((void *) this, &p); Index: netInterface.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/netInterface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** netInterface.cpp 24 Apr 2004 23:52:33 -0000 1.2 --- netInterface.cpp 11 May 2004 18:26:24 -0000 1.3 *************** *** 320,333 **** mConnectionList[i]->checkPacketSend(false, time); - // check if we're trying to solve any client connection puzzles - for(S32 i = 0; i < mPendingConnections.size(); i++) - { - if(mPendingConnections[i]->getConnectionState() == NetConnection::ComputingPuzzleSolution) - { - continuePuzzleSolution(mPendingConnections[i]); - break; - } - } - if(time > mLastTimeoutCheckTime + TimeoutCheckInterval) { --- 320,323 ---- *************** *** 403,406 **** --- 393,406 ---- } } + + // check if we're trying to solve any client connection puzzles + for(S32 i = 0; i < mPendingConnections.size(); i++) + { + if(mPendingConnections[i]->getConnectionState() == NetConnection::ComputingPuzzleSolution) + { + continuePuzzleSolution(mPendingConnections[i]); + break; + } + } } |