Update of /cvsroot/opentnl/tnl/tnl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28526/tnl
Modified Files:
journal.cpp netConnection.cpp platform.cpp tnl.vcproj
tnlJournal.h udp.cpp
Log Message:
Made Zap master connection client adaptive
Added buncha stuff to journaling
Fixed nasty netConnection bug (thanks, Journaling!)
Index: platform.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/platform.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** platform.cpp 11 May 2004 02:45:26 -0000 1.3
--- platform.cpp 12 May 2004 01:37:59 -0000 1.4
***************
*** 143,147 ****
U32 tickCount;
TNL_JOURNAL_READ_BLOCK
! (
TNL_JOURNAL_READ( (&tickCount) );
return tickCount;
--- 143,147 ----
U32 tickCount;
TNL_JOURNAL_READ_BLOCK
! ( 2001,
TNL_JOURNAL_READ( (&tickCount) );
return tickCount;
***************
*** 151,155 ****
TNL_JOURNAL_WRITE_BLOCK
! (
TNL_JOURNAL_WRITE( (tickCount) );
)
--- 151,155 ----
TNL_JOURNAL_WRITE_BLOCK
! ( 2001,
TNL_JOURNAL_WRITE( (tickCount) );
)
***************
*** 197,201 ****
S64 currentTime;
TNL_JOURNAL_READ_BLOCK
! (
TNL_JOURNAL_READ( (¤tTime) );
return currentTime;
--- 197,201 ----
S64 currentTime;
TNL_JOURNAL_READ_BLOCK
! ( 2003,
TNL_JOURNAL_READ( (¤tTime) );
return currentTime;
***************
*** 205,209 ****
TNL_JOURNAL_WRITE_BLOCK
! (
TNL_JOURNAL_WRITE( (currentTime) );
)
--- 205,209 ----
TNL_JOURNAL_WRITE_BLOCK
! ( 2003,
TNL_JOURNAL_WRITE( (currentTime) );
)
***************
*** 216,220 ****
F64 timerValue;
TNL_JOURNAL_READ_BLOCK
! (
TNL_JOURNAL_READ( (&timerValue) );
return timerValue;
--- 216,220 ----
F64 timerValue;
TNL_JOURNAL_READ_BLOCK
! ( 2002,
TNL_JOURNAL_READ( (&timerValue) );
return timerValue;
***************
*** 224,228 ****
TNL_JOURNAL_WRITE_BLOCK
! (
TNL_JOURNAL_WRITE( (timerValue) );
)
--- 224,228 ----
TNL_JOURNAL_WRITE_BLOCK
! ( 2002,
TNL_JOURNAL_WRITE( (timerValue) );
)
Index: tnlJournal.h
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/tnlJournal.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tnlJournal.h 11 May 2004 18:26:24 -0000 1.3
--- tnlJournal.h 12 May 2004 01:37:59 -0000 1.4
***************
*** 32,36 ****
#define TNL_ENABLE_JOURNALING
!
namespace TNL
{
--- 32,36 ----
#define TNL_ENABLE_JOURNALING
! //#define TNL_ENABLE_BIG_JOURNALS
namespace TNL
{
***************
*** 48,51 ****
--- 48,54 ----
static Journal *mJournal;
static U32 mWritePosition;
+ static U32 mReadBreakBitPos;
+ static U32 mBreakBlockIndex;
+ static U32 mBlockIndex;
public:
enum Mode
***************
*** 58,61 ****
--- 61,66 ----
static Mode mCurrentMode;
static bool mInsideEntrypoint;
+ static void checkReadPosition();
+ static void syncWriteStream();
public:
Journal();
***************
*** 68,76 ****
static Mode getCurrentMode() { return mCurrentMode; }
static Journal *get() { return mJournal; }
- static void checkReadPosition();
- static void syncWriteStream();
static BitStream *getReadStream() { return &mReadStream; }
static BitStream *getWriteStream() { return &mWriteStream; }
static bool isInEntrypoint() { return mInsideEntrypoint; }
};
--- 73,82 ----
static Mode getCurrentMode() { return mCurrentMode; }
static Journal *get() { return mJournal; }
static BitStream *getReadStream() { return &mReadStream; }
static BitStream *getWriteStream() { return &mWriteStream; }
static bool isInEntrypoint() { return mInsideEntrypoint; }
+
+ static void beginBlock(U32 blockId, bool writeBlock);
+ static void endBlock(U32 blockId, bool writeBlock);
};
***************
*** 113,139 ****
void FN_CDECL className::func##_body args
! #define TNL_JOURNAL_WRITE_BLOCK(x) \
! { \
! if(TNL::Journal::getCurrentMode() == TNL::Journal::Record && TNL::Journal::isInEntrypoint()) \
! { \
! x \
! } \
! TNL::Journal::syncWriteStream(); \
! }
!
! class JournalReadChecker
{
public:
! ~JournalReadChecker()
{
! TNL::Journal::checkReadPosition();
}
};
! #define TNL_JOURNAL_READ_BLOCK(x) \
{ \
! if(TNL::Journal::isInEntrypoint()) { \
! TNL::JournalReadChecker dummy; \
! if(TNL::Journal::getCurrentMode() == TNL::Journal::Playback) \
{ \
x \
--- 119,156 ----
void FN_CDECL className::func##_body args
! class JournalToken
{
+ bool mWriting;
+ U32 mBlockType;
public:
! JournalToken(U32 blockType, bool writing)
{
! mWriting = writing;
! mBlockType = blockType;
! TNL::Journal::beginBlock(mBlockType, mWriting);
! }
!
! ~JournalToken()
! {
! TNL::Journal::endBlock(mBlockType, mWriting);
}
};
! #define TNL_JOURNAL_WRITE_BLOCK(blockType, x) \
{ \
! if(TNL::Journal::getCurrentMode() == TNL::Journal::Record && TNL::Journal::isInEntrypoint()) \
! { \
! TNL::JournalToken dummy(blockType, true); \
! { \
! x \
! } \
! } \
! }
!
! #define TNL_JOURNAL_READ_BLOCK(blockType, x) \
! { \
! if(TNL::Journal::getCurrentMode() == TNL::Journal::Playback && TNL::Journal::isInEntrypoint()) \
! { \
! TNL::JournalToken dummy(blockType, false); \
{ \
x \
Index: udp.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/udp.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** udp.cpp 11 May 2004 02:45:26 -0000 1.3
--- udp.cpp 12 May 2004 01:37:59 -0000 1.4
***************
*** 191,195 ****
Socket::Socket(const Address &bindAddress, U32 sendBufferSize, U32 recvBufferSize, bool acceptsBroadcast, bool nonblockingIO)
{
! TNL_JOURNAL_READ_BLOCK(
TNL_JOURNAL_READ( (&mPlatformSocket) );
return;
--- 191,195 ----
Socket::Socket(const Address &bindAddress, U32 sendBufferSize, U32 recvBufferSize, bool acceptsBroadcast, bool nonblockingIO)
{
! TNL_JOURNAL_READ_BLOCK(1001,
TNL_JOURNAL_READ( (&mPlatformSocket) );
return;
***************
*** 271,275 ****
}
}
! TNL_JOURNAL_WRITE_BLOCK(
TNL_JOURNAL_WRITE( (mPlatformSocket) );
)
--- 271,275 ----
}
}
! TNL_JOURNAL_WRITE_BLOCK(1001,
TNL_JOURNAL_WRITE( (mPlatformSocket) );
)
***************
*** 278,285 ****
Socket::~Socket()
{
! TNL_JOURNAL_READ_BLOCK(
return;
)
if(mPlatformSocket != INVALID_SOCKET)
closesocket(mPlatformSocket);
--- 278,287 ----
Socket::~Socket()
{
! TNL_JOURNAL_READ_BLOCK(1002,
return;
)
+ TNL_JOURNAL_WRITE_BLOCK(1002, ;)
+
if(mPlatformSocket != INVALID_SOCKET)
closesocket(mPlatformSocket);
***************
*** 289,296 ****
NetError Socket::sendto(const Address &address, const U8 *buffer, S32 bufferSize)
{
! TNL_JOURNAL_READ_BLOCK(
return NoError;
)
if(address.transport != mTransportProtocol)
return InvalidPacketProtocol;
--- 291,301 ----
NetError Socket::sendto(const Address &address, const U8 *buffer, S32 bufferSize)
{
! TNL_JOURNAL_READ_BLOCK(1003,
return NoError;
)
+ TNL_JOURNAL_WRITE_BLOCK(1003, ;
+ )
+
if(address.transport != mTransportProtocol)
return InvalidPacketProtocol;
***************
*** 309,313 ****
NetError Socket::recvfrom(Address *address, U8 *buffer, S32 bufferSize, S32 *outSize)
{
! TNL_JOURNAL_READ_BLOCK(
bool wouldBlock;
TNL_JOURNAL_READ( (&wouldBlock) );
--- 314,318 ----
NetError Socket::recvfrom(Address *address, U8 *buffer, S32 bufferSize, S32 *outSize)
{
! TNL_JOURNAL_READ_BLOCK(1004,
bool wouldBlock;
TNL_JOURNAL_READ( (&wouldBlock) );
***************
*** 333,337 ****
if(bytesRead == SOCKET_ERROR)
{
! TNL_JOURNAL_WRITE_BLOCK(
TNL_JOURNAL_WRITE ( (true) );
)
--- 338,342 ----
if(bytesRead == SOCKET_ERROR)
{
! TNL_JOURNAL_WRITE_BLOCK(1004,
TNL_JOURNAL_WRITE ( (true) );
)
***************
*** 343,347 ****
*outSize = bytesRead;
! TNL_JOURNAL_WRITE_BLOCK(
TNL_JOURNAL_WRITE( (false) );
TNL_JOURNAL_WRITE( (address->transport) );
--- 348,352 ----
*outSize = bytesRead;
! TNL_JOURNAL_WRITE_BLOCK(1004,
TNL_JOURNAL_WRITE( (false) );
TNL_JOURNAL_WRITE( (address->transport) );
Index: tnl.vcproj
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/tnl.vcproj,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tnl.vcproj 10 May 2004 22:34:23 -0000 1.3
--- tnl.vcproj 12 May 2004 01:37:59 -0000 1.4
***************
*** 75,79 ****
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../libtomcrypt"
! PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="TRUE"
ExceptionHandling="FALSE"
--- 75,79 ----
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../libtomcrypt"
! PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TNL_ENABLE_LOGGING"
StringPooling="TRUE"
ExceptionHandling="FALSE"
Index: journal.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/journal.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** journal.cpp 11 May 2004 18:26:24 -0000 1.3
--- journal.cpp 12 May 2004 01:37:59 -0000 1.4
***************
*** 27,30 ****
--- 27,31 ----
#include "tnlJournal.h"
#include "tnlEndian.h"
+ #include "tnlLog.h"
namespace TNL
***************
*** 35,38 ****
--- 36,40 ----
bool Journal::mInsideEntrypoint = false;
Journal::Mode Journal::mCurrentMode = Journal::Inactive;
+ U32 Journal::mReadBreakBitPos = 0;
FILE *Journal::mJournalFile = NULL;
***************
*** 41,44 ****
--- 43,48 ----
Journal *Journal::mJournal = NULL;
U32 Journal::mWritePosition = 0;
+ U32 Journal::mBreakBlockIndex = 0;
+ U32 Journal::mBlockIndex = 0;
JournalEntryRecord::JournalEntryRecord(const char *functionName, MethodArgList *methodArgList)
***************
*** 141,144 ****
--- 145,152 ----
mReadStream.read(&bitCount);
mReadStream.setMaxBitSizes(bitCount);
+
+ if(!mReadBreakBitPos || mReadBreakBitPos > bitCount)
+ mReadBreakBitPos = bitCount;
+
fclose(theJournal);
mCurrentMode = Playback;
***************
*** 163,168 ****
--- 171,182 ----
if(mCurrentMode == Record)
{
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ TNL_JOURNAL_WRITE( (U16(0x1234)) );
+ #endif
mWriteStream.writeRangedU32(entryIndex, 0, JournalEntryRecord::mEntryVector->size() - 1);
mWriteStream.writeBits(theCall->marshalledData.getBitPosition(), theCall->marshalledData.getBuffer());
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ TNL_JOURNAL_WRITE( (U16(0x5678)) );
+ #endif
syncWriteStream();
}
***************
*** 180,187 ****
void Journal::checkReadPosition()
{
! if(!mReadStream.isValid() || mReadStream.getBitPosition() == mReadStream.getMaxReadBitPosition())
TNL_DEBUGBREAK();
}
void Journal::processNextJournalEntry()
{
--- 194,251 ----
void Journal::checkReadPosition()
{
! if(!mReadStream.isValid() || mReadStream.getBitPosition() >= mReadBreakBitPos)
TNL_DEBUGBREAK();
}
+ void Journal::beginBlock(U32 blockId, bool writeBlock)
+ {
+ if(writeBlock)
+ {
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ TNL_JOURNAL_WRITE( (U16(0x1234 ^ blockId)) );
+ #endif
+ }
+ else
+ {
+ mBlockIndex++;
+ if(mBreakBlockIndex && mBlockIndex >= mBreakBlockIndex)
+ TNL_DEBUGBREAK();
+
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ U16 startToken;
+ TNL_JOURNAL_READ( (&startToken) );
+ if((startToken ^ 0x1234) != blockId)
+ {
+ logprintf("Expected token %d - got %d", blockId, startToken ^ 0x1234);
+ TNL_DEBUGBREAK();
+ }
+ #endif
+ }
+ }
+
+ void Journal::endBlock(U32 blockId, bool writeBlock)
+ {
+ if(writeBlock)
+ {
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ TNL_JOURNAL_WRITE( (U16(0x5678 ^ blockId)) );
+ #endif
+ syncWriteStream();
+ }
+ else
+ {
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ U16 endToken;
+ TNL_JOURNAL_READ( (&endToken) );
+ if((endToken ^ 0x5678) != blockId)
+ {
+ logprintf("Expected token %d - got %d", blockId, endToken ^ 0x5678);
+ TNL_DEBUGBREAK();
+ }
+ #endif
+ checkReadPosition();
+ }
+ }
+
void Journal::processNextJournalEntry()
{
***************
*** 189,192 ****
--- 253,263 ----
return;
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ U16 token;
+ TNL_JOURNAL_READ( (&token) );
+ if(token != 0x1234)
+ TNL_DEBUGBREAK();
+ #endif
+
U32 index = mReadStream.readRangedU32(0, JournalEntryRecord::mEntryVector->size());
***************
*** 203,206 ****
--- 274,284 ----
MarshalledCall theCall(theEntry->mMethodArgList);
theCall.unmarshall(&mReadStream);
+
+ #ifdef TNL_ENABLE_BIG_JOURNALS
+ TNL_JOURNAL_READ( (&token) );
+ if(token != 0x5678)
+ TNL_DEBUGBREAK();
+ #endif
+
checkReadPosition();
Index: netConnection.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/tnl/netConnection.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** netConnection.cpp 24 Apr 2004 23:52:32 -0000 1.2
--- netConnection.cpp 12 May 2004 01:37:59 -0000 1.3
***************
*** 206,210 ****
mNotifyQueueTail = note;
note->nextPacket = NULL;
! note->sendTime = mLastUpdateTime;
writePacketRateInfo(bstream, note);
--- 206,210 ----
mNotifyQueueTail = note;
note->nextPacket = NULL;
! note->sendTime = Platform::getRealMilliseconds();
writePacketRateInfo(bstream, note);
***************
*** 245,248 ****
--- 245,251 ----
void NetConnection::writePacketHeader(BitStream *stream, NetPacketType packetType)
{
+ if(windowFull() && packetType == DataPacket)
+ TNL_DEBUGBREAK();
+
S32 ackByteCount = ((mLastSeqRecvd - mLastRecvAckAck + 7) >> 3);
TNLAssert(ackByteCount <= MaxAckByteCount, "ackByteCount exceeds MaxAckByteCount!");
***************
*** 278,281 ****
--- 281,290 ----
mLastSeqRecvdAtSend[mLastSendSeq & PacketWindowMask] = mLastSeqRecvd;
+ //if(isNetworkConnection())
+ //{
+ // TNLLogMessageV(LogBlah, ("SND: mLSQ: %08x pkLS: %08x pt: %d abc: %d",
+ // mLastSendSeq, mLastSeqRecvd, packetType, ackByteCount));
+ //}
+
TNLLogMessageV(LogConnectionProtocol, ("build hdr %d %d", mLastSendSeq, packetType));
}
***************
*** 347,351 ****
return false;
}
!
if(!mSymmetricCipher.isNull())
{
--- 356,360 ----
return false;
}
!
if(!mSymmetricCipher.isNull())
{
***************
*** 359,363 ****
return false;
! U32 pkAckMask[MaxAckByteCount];
U32 pkAckWordCount = (pkAckByteCount + 3) >> 2;
--- 368,372 ----
return false;
! U32 pkAckMask[MaxAckMaskSize];
U32 pkAckWordCount = (pkAckByteCount + 3) >> 2;
***************
*** 366,369 ****
--- 375,384 ----
(pkAckByteCount - (i * 4)) * 8 : 32);
+ //if(isNetworkConnection())
+ //{
+ // TNLLogMessageV(LogBlah, ("RCV: mHA: %08x pkHA: %08x mLSQ: %08x pkSN: %08x pkLS: %08x pkAM: %08x",
+ // mHighestAckedSeq, pkHighestAck, mLastSendSeq, pkSequenceNumber, mLastSeqRecvd, pkAckMask[0]));
+ //}
+
U32 pkSendDelay = (pstream->readInt(8) << 3) + 4;
***************
*** 560,564 ****
// We are in normal state..
if(cwnd < MaxPacketWindowSize-2)
! cwnd += (1 < 1/cwnd) ? 1 : (1/cwnd);
TNLLogMessageV(LogNetConnection, ("PKT OK - ssthresh = %f cwnd=%f", ssthresh, cwnd));
--- 575,579 ----
// We are in normal state..
if(cwnd < MaxPacketWindowSize-2)
! cwnd += 1/cwnd;
TNLLogMessageV(LogNetConnection, ("PKT OK - ssthresh = %f cwnd=%f", ssthresh, cwnd));
***************
*** 637,642 ****
sendAckPacket();
}
- return;
}
}
PacketStream stream(mCurrentPacketSendSize);
--- 652,657 ----
sendAckPacket();
}
}
+ return;
}
PacketStream stream(mCurrentPacketSendSize);
***************
*** 650,657 ****
bool NetConnection::windowFull()
{
if(isAdaptive())
! return mLastSendSeq - mHighestAckedSeq >= cwnd;
! else
! return mLastSendSeq - mHighestAckedSeq >= (MaxPacketWindowSize - 2);
}
--- 665,673 ----
bool NetConnection::windowFull()
{
+ if(mLastSendSeq - mHighestAckedSeq >= (MaxPacketWindowSize - 2))
+ return true;
if(isAdaptive())
! return mLastSendSeq - mHighestAckedSeq >= cwnd;
! return false;
}
|