diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-08-15 22:47:44 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-08-15 22:47:44 +0000 |
commit | 4458bf17916973aeb9e99e9166070f645fb3295e (patch) | |
tree | 26dee42145e176b7ec3c3f233c79afc7b3270557 /lib/common/StreamableMemBlock.cpp | |
parent | 06960c6241f6209b6dd19b4c204c27f1395cda7d (diff) |
Fix deadlock waiting for read or write on closed connection.
If the system is suspended then it may not realise that a TCP connection has
been closed, while waiting for data to arrive on it. We didn't used to apply
a timeout to this read operation. Now we use the connection's default timeout
on all read and write operations. Network operations that don't pass a timeout
will be logged with a backtrace, so that they can be fixed.
Diffstat (limited to 'lib/common/StreamableMemBlock.cpp')
-rw-r--r-- | lib/common/StreamableMemBlock.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/common/StreamableMemBlock.cpp b/lib/common/StreamableMemBlock.cpp index b376f037..be3d0031 100644 --- a/lib/common/StreamableMemBlock.cpp +++ b/lib/common/StreamableMemBlock.cpp @@ -252,7 +252,9 @@ void StreamableMemBlock::ReadFromStream(IOStream &rStream, int Timeout) { // Get the size of the block int32_t size_s; - if(!rStream.ReadFullBuffer(&size_s, sizeof(size_s), 0 /* not interested in bytes read if this fails */)) + if(!rStream.ReadFullBuffer(&size_s, sizeof(size_s), + 0, /* not interested in bytes read if this fails */ + Timeout)) { THROW_EXCEPTION(CommonException, StreamableMemBlockIncompleteRead) } @@ -270,7 +272,9 @@ void StreamableMemBlock::ReadFromStream(IOStream &rStream, int Timeout) try { // Read in - if(!rStream.ReadFullBuffer(pblock, size, 0 /* not interested in bytes read if this fails */)) + if(!rStream.ReadFullBuffer(pblock, size, + 0, /* not interested in bytes read if this fails */ + Timeout)) { THROW_EXCEPTION(CommonException, StreamableMemBlockIncompleteRead) } |