summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/common/IOStream.cpp2
-rw-r--r--lib/common/IOStream.h2
-rw-r--r--lib/compress/CompressStream.cpp14
-rw-r--r--lib/compress/CompressStream.h8
-rw-r--r--lib/server/Protocol.cpp15
-rw-r--r--lib/server/SocketStreamTLS.cpp6
-rw-r--r--test/compress/testcompress.cpp5
7 files changed, 28 insertions, 24 deletions
diff --git a/lib/common/IOStream.cpp b/lib/common/IOStream.cpp
index 71e8f8c0..35219549 100644
--- a/lib/common/IOStream.cpp
+++ b/lib/common/IOStream.cpp
@@ -165,7 +165,7 @@ bool IOStream::ReadFullBuffer(void *pBuffer, int NBytes, int *pNBytesRead, int T
// Created: 2003/08/26
//
// --------------------------------------------------------------------------
-void IOStream::WriteAllBuffered()
+void IOStream::WriteAllBuffered(int Timeout)
{
}
diff --git a/lib/common/IOStream.h b/lib/common/IOStream.h
index a4eb3db1..80915d71 100644
--- a/lib/common/IOStream.h
+++ b/lib/common/IOStream.h
@@ -50,7 +50,7 @@ public:
virtual void Write(const void *pBuffer, int NBytes,
int Timeout = IOStream::TimeOutInfinite) = 0;
virtual void Write(const char *pBuffer);
- virtual void WriteAllBuffered();
+ virtual void WriteAllBuffered(int Timeout = IOStream::TimeOutInfinite);
virtual pos_type GetPosition() const;
virtual void Seek(pos_type Offset, int SeekType);
virtual void Close();
diff --git a/lib/compress/CompressStream.cpp b/lib/compress/CompressStream.cpp
index 9bb73e3d..f7728a21 100644
--- a/lib/compress/CompressStream.cpp
+++ b/lib/compress/CompressStream.cpp
@@ -177,12 +177,12 @@ int CompressStream::Read(void *pBuffer, int NBytes, int Timeout)
// Created: 27/5/04
//
// --------------------------------------------------------------------------
-void CompressStream::Write(const void *pBuffer, int NBytes)
+void CompressStream::Write(const void *pBuffer, int NBytes, int Timeout)
{
USE_WRITE_COMPRESSOR
if(pCompress == 0)
{
- mpStream->Write(pBuffer, NBytes);
+ mpStream->Write(pBuffer, NBytes, Timeout);
return;
}
@@ -207,7 +207,7 @@ void CompressStream::Write(const void *pBuffer, int NBytes)
// Created: 27/5/04
//
// --------------------------------------------------------------------------
-void CompressStream::WriteAllBuffered()
+void CompressStream::WriteAllBuffered(int Timeout)
{
if(mIsClosed)
{
@@ -215,7 +215,7 @@ void CompressStream::WriteAllBuffered()
}
// Just ask compressed data to be written out, but with the sync flag set
- WriteCompressedData(true);
+ WriteCompressedData(true, Timeout);
}
@@ -238,7 +238,7 @@ void CompressStream::Close()
pCompress->FinishInput();
WriteCompressedData();
- // Mark as definately closed
+ // Mark as definitely closed
mIsClosed = true;
}
}
@@ -257,7 +257,7 @@ void CompressStream::Close()
// Created: 28/5/04
//
// --------------------------------------------------------------------------
-void CompressStream::WriteCompressedData(bool SyncFlush)
+void CompressStream::WriteCompressedData(bool SyncFlush, int Timeout)
{
USE_WRITE_COMPRESSOR
if(pCompress == 0) {THROW_EXCEPTION(CompressException, Internal)}
@@ -268,7 +268,7 @@ void CompressStream::WriteCompressedData(bool SyncFlush)
s = pCompress->Output(mpBuffer, BUFFER_SIZE, SyncFlush);
if(s > 0)
{
- mpStream->Write(mpBuffer, s);
+ mpStream->Write(mpBuffer, s, Timeout);
}
} while(s > 0);
// Check assumption -- all input has been consumed
diff --git a/lib/compress/CompressStream.h b/lib/compress/CompressStream.h
index 7959e3dc..7d6b2501 100644
--- a/lib/compress/CompressStream.h
+++ b/lib/compress/CompressStream.h
@@ -33,8 +33,9 @@ private:
public:
virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
- virtual void Write(const void *pBuffer, int NBytes);
- virtual void WriteAllBuffered();
+ virtual void Write(const void *pBuffer, int NBytes,
+ int Timeout = IOStream::TimeOutInfinite);
+ virtual void WriteAllBuffered(int Timeout = IOStream::TimeOutInfinite);
virtual void Close();
virtual bool StreamDataLeft();
virtual bool StreamClosed();
@@ -43,7 +44,8 @@ protected:
void CheckRead();
void CheckWrite();
void CheckBuffer();
- void WriteCompressedData(bool SyncFlush = false);
+ void WriteCompressedData(bool SyncFlush = false,
+ int Timeout = IOStream::TimeOutInfinite);
private:
IOStream *mpStream;
diff --git a/lib/server/Protocol.cpp b/lib/server/Protocol.cpp
index 15fb4139..7e581213 100644
--- a/lib/server/Protocol.cpp
+++ b/lib/server/Protocol.cpp
@@ -104,7 +104,7 @@ void Protocol::Handshake()
::strncpy(hsSend.mIdent, GetProtocolIdentString(), sizeof(hsSend.mIdent));
// Send it
- mapConn->Write(&hsSend, sizeof(hsSend));
+ mapConn->Write(&hsSend, sizeof(hsSend), GetTimeout());
mapConn->WriteAllBuffered();
// Receive a handshake from the peer
@@ -115,7 +115,7 @@ void Protocol::Handshake()
while(bytesToRead > 0)
{
// Get some data from the stream
- int bytesRead = mapConn->Read(readInto, bytesToRead, mTimeout);
+ int bytesRead = mapConn->Read(readInto, bytesToRead, GetTimeout());
if(bytesRead == 0)
{
THROW_EXCEPTION(ConnectionException, Protocol_Timeout)
@@ -296,7 +296,7 @@ void Protocol::SendInternal(const Message &rObject)
pobjHeader->mObjType = htonl(rObject.GetType());
// Write data
- mapConn->Write(mpBuffer, writtenSize);
+ mapConn->Write(mpBuffer, writtenSize, GetTimeout());
mapConn->WriteAllBuffered();
}
@@ -713,7 +713,7 @@ void Protocol::SendStream(IOStream &rStream)
objHeader.mObjType = htonl(SPECIAL_STREAM_OBJECT_TYPE);
// Write header
- mapConn->Write(&objHeader, sizeof(objHeader));
+ mapConn->Write(&objHeader, sizeof(objHeader), GetTimeout());
// Could be sent in one of two ways
if(uncertainSize)
{
@@ -748,7 +748,7 @@ void Protocol::SendStream(IOStream &rStream)
// Send final byte to finish the stream
BOX_TRACE("Sending end of stream byte");
uint8_t endOfStream = ProtocolStreamHeader_EndOfStream;
- mapConn->Write(&endOfStream, 1);
+ mapConn->Write(&endOfStream, 1, GetTimeout());
BOX_TRACE("Sent end of stream byte");
}
catch(...)
@@ -763,7 +763,8 @@ void Protocol::SendStream(IOStream &rStream)
else
{
// Fixed size stream, send it all in one go
- if(!rStream.CopyStreamTo(*mapConn, mTimeout, 4096 /* slightly larger buffer */))
+ if(!rStream.CopyStreamTo(*mapConn, GetTimeout(),
+ 4096 /* slightly larger buffer */))
{
THROW_EXCEPTION(ConnectionException, Protocol_TimeOutWhenSendingStream)
}
@@ -820,7 +821,7 @@ int Protocol::SendStreamSendBlock(uint8_t *Block, int BytesInBlock)
Block[-1] = header;
// Write everything out
- mapConn->Write(Block - 1, writeSize + 1);
+ mapConn->Write(Block - 1, writeSize + 1, GetTimeout());
BOX_TRACE("Sent " << (writeSize+1) << " bytes to stream");
// move the remainer to the beginning of the block for the next time round
diff --git a/lib/server/SocketStreamTLS.cpp b/lib/server/SocketStreamTLS.cpp
index 6ca172f6..e31ac13f 100644
--- a/lib/server/SocketStreamTLS.cpp
+++ b/lib/server/SocketStreamTLS.cpp
@@ -356,12 +356,12 @@ void SocketStreamTLS::Write(const void *pBuffer, int NBytes, int Timeout)
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
- // wait for the requried data
+ // wait for the required data
{
#ifndef BOX_RELEASE_BUILD
- bool conditionmet =
+ bool conditionmet =
#endif
- WaitWhenRetryRequired(se, IOStream::TimeOutInfinite);
+ WaitWhenRetryRequired(se, Timeout);
ASSERT(conditionmet);
}
break;
diff --git a/test/compress/testcompress.cpp b/test/compress/testcompress.cpp
index 4a522d31..76512e6a 100644
--- a/test/compress/testcompress.cpp
+++ b/test/compress/testcompress.cpp
@@ -47,9 +47,10 @@ public:
return 0;
}
- void Write(const void *pBuffer, int NBytes)
+ void Write(const void *pBuffer, int NBytes,
+ int Timeout = IOStream::TimeOutInfinite)
{
- buffers[(currentBuffer + 1) & 1].Write(pBuffer, NBytes);
+ buffers[(currentBuffer + 1) & 1].Write(pBuffer, NBytes, Timeout);
}
bool StreamDataLeft()
{