summaryrefslogtreecommitdiff
path: root/lib/server/ProtocolUncertainStream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server/ProtocolUncertainStream.cpp')
-rw-r--r--lib/server/ProtocolUncertainStream.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/server/ProtocolUncertainStream.cpp b/lib/server/ProtocolUncertainStream.cpp
index 60c1fa1d..84a213a8 100644
--- a/lib/server/ProtocolUncertainStream.cpp
+++ b/lib/server/ProtocolUncertainStream.cpp
@@ -41,7 +41,8 @@ ProtocolUncertainStream::~ProtocolUncertainStream()
{
if(!mFinished)
{
- TRACE0("ProtocolUncertainStream::~ProtocolUncertainStream() destroyed when stream not complete\n");
+ BOX_WARNING("ProtocolUncertainStream destroyed before "
+ "stream finished");
}
}
@@ -76,11 +77,15 @@ int ProtocolUncertainStream::Read(void *pBuffer, int NBytes, int Timeout)
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;
}
@@ -91,16 +96,22 @@ int ProtocolUncertainStream::Read(void *pBuffer, int NBytes, int Timeout)
// 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;
}
}
else
{
- // Read the header byte to find out how much there is in the next block
+ // Read the header byte to find out how much there is
+ // in the next block
uint8_t header;
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;
}
@@ -109,6 +120,8 @@ int ProtocolUncertainStream::Read(void *pBuffer, int NBytes, int Timeout)
{
// All done.
mFinished = true;
+ BOX_TRACE("Stream finished, returning with " <<
+ read << " bytes read this time");
return read;
}
else if(header <= Protocol::ProtocolStreamHeader_MaxEncodedSizeValue)
@@ -126,6 +139,10 @@ int ProtocolUncertainStream::Read(void *pBuffer, int NBytes, int Timeout)
// Bad. It used the reserved values.
THROW_EXCEPTION(ServerException, ProtocolUncertainStreamBadBlockHeader)
}
+
+ BOX_TRACE("Read header byte " << (int)header << ", "
+ "next block has " <<
+ mBytesLeftInCurrentBlock << " bytes");
}
}