summaryrefslogtreecommitdiff
path: root/lib/server/Protocol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server/Protocol.cpp')
-rw-r--r--lib/server/Protocol.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/server/Protocol.cpp b/lib/server/Protocol.cpp
index 4398a58f..5dc5d0b1 100644
--- a/lib/server/Protocol.cpp
+++ b/lib/server/Protocol.cpp
@@ -26,7 +26,7 @@
#include "MemLeakFindOn.h"
-#ifdef NDEBUG
+#ifdef BOX_RELEASE_BUILD
#define PROTOCOL_ALLOCATE_SEND_BLOCK_CHUNK 1024
#else
// #define PROTOCOL_ALLOCATE_SEND_BLOCK_CHUNK 1024
@@ -670,9 +670,18 @@ std::auto_ptr<IOStream> Protocol::ReceiveStream()
InformStreamReceiving(streamSize);
// Return a stream object
- return std::auto_ptr<IOStream>((streamSize == ProtocolStream_SizeUncertain)?
- ((IOStream*)(new ProtocolUncertainStream(mrStream)))
- :((IOStream*)(new PartialReadStream(mrStream, streamSize))));
+ if(streamSize == ProtocolStream_SizeUncertain)
+ {
+ BOX_TRACE("Receiving stream, size uncertain");
+ return std::auto_ptr<IOStream>(
+ new ProtocolUncertainStream(mrStream));
+ }
+ else
+ {
+ BOX_TRACE("Receiving stream, size " << streamSize << " bytes");
+ return std::auto_ptr<IOStream>(
+ new PartialReadStream(mrStream, streamSize));
+ }
}
// --------------------------------------------------------------------------
@@ -749,8 +758,10 @@ void Protocol::SendStream(IOStream &rStream)
}
// 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 +799,7 @@ int Protocol::SendStreamSendBlock(uint8_t *Block, int BytesInBlock)
// Quick sanity check
if(BytesInBlock == 0)
{
+ BOX_TRACE("Zero size block, not sending anything");
return 0;
}
@@ -813,6 +825,8 @@ int Protocol::SendStreamSendBlock(uint8_t *Block, int BytesInBlock)
}
}
ASSERT(header > 0);
+ BOX_TRACE("Sending header byte " << (int)header << " plus " <<
+ writeSize << " bytes to stream");
// Store the header
Block[-1] = header;
@@ -820,6 +834,7 @@ int Protocol::SendStreamSendBlock(uint8_t *Block, int BytesInBlock)
// 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)
{