[Box Backup-commit] COMMIT r2303 - box/trunk/lib/server
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Tue, 30 Sep 2008 22:07:37 +0100 (BST)
Author: chris
Date: 2008-09-30 22:07:36 +0100 (Tue, 30 Sep 2008)
New Revision: 2303
Modified:
box/trunk/lib/server/Protocol.cpp
box/trunk/lib/server/ProtocolUncertainStream.cpp
Log:
Additional debugging for protocol stream deadlock reported by
Matt Brown.
Modified: box/trunk/lib/server/Protocol.cpp
===================================================================
--- box/trunk/lib/server/Protocol.cpp 2008-09-26 22:18:35 UTC (rev 2302)
+++ box/trunk/lib/server/Protocol.cpp 2008-09-30 21:07:36 UTC (rev 2303)
@@ -749,8 +749,10 @@
}
// Send final byte to finish the stream
+ BOX_TRACE("Sending end of stream byte");
uint8_t endOfStream = ProtocolStreamHeader_EndOfStream;
mrStream.Write(&endOfStream, 1);
+ BOX_TRACE("Sent end of stream byte");
}
catch(...)
{
@@ -788,6 +790,7 @@
// Quick sanity check
if(BytesInBlock == 0)
{
+ BOX_TRACE("Zero size block, not sending anything");
return 0;
}
@@ -813,6 +816,8 @@
}
}
ASSERT(header > 0);
+ BOX_TRACE("Sending header byte " << header << " plus " << writeSize <<
+ " bytes to stream");
// Store the header
Block[-1] = header;
@@ -820,6 +825,7 @@
// Write everything out
mrStream.Write(Block - 1, writeSize + 1);
+ BOX_TRACE("Sent " << (writeSize+1) << " bytes to stream");
// move the remainer to the beginning of the block for the next time round
if(writeSize != BytesInBlock)
{
Modified: box/trunk/lib/server/ProtocolUncertainStream.cpp
===================================================================
--- box/trunk/lib/server/ProtocolUncertainStream.cpp 2008-09-26 22:18:35 UTC (rev 2302)
+++ box/trunk/lib/server/ProtocolUncertainStream.cpp 2008-09-30 21:07:36 UTC (rev 2303)
@@ -77,11 +77,15 @@
toRead = mBytesLeftInCurrentBlock;
}
+ BOX_TRACE("Reading " << toRead << " bytes from stream");
+
// Read it
int r = mrSource.Read(((uint8_t*)pBuffer) + read, toRead, Timeout);
// Give up now if it didn't return anything
if(r == 0)
{
+ BOX_TRACE("Read " << r << " bytes from "
+ "stream, returning");
return read;
}
@@ -92,6 +96,8 @@
// stop now if the stream returned less than we asked for -- avoid blocking
if(r != toRead)
{
+ BOX_TRACE("Read " << r << " bytes from "
+ "stream, returning");
return read;
}
}
@@ -102,6 +108,9 @@
if(mrSource.Read(&header, 1, Timeout) == 0)
{
// Didn't get the byte, return now
+ BOX_TRACE("Read 0 bytes of block header, "
+ "returning with " << read << " bytes "
+ "read this time");
return read;
}
@@ -110,6 +119,8 @@
{
// All done.
mFinished = true;
+ BOX_TRACE("Stream finished, returning with " <<
+ read << " bytes read this time");
return read;
}
else if(header <= Protocol::ProtocolStreamHeader_MaxEncodedSizeValue)
@@ -127,6 +138,9 @@
// Bad. It used the reserved values.
THROW_EXCEPTION(ServerException, ProtocolUncertainStreamBadBlockHeader)
}
+
+ BOX_TRACE("Next block has " <<
+ mBytesLeftInCurrentBlock << "bytes");
}
}