Permalink
Browse files

CSHARP-717: Fix regression where reading from a socket that has been …

…closed by the server is now hanging instead of throwing an EndOfStreamException.
  • Loading branch information...
1 parent 2b69d85 commit 92b8bde6932fa47ab1edb69b9cdb70386c6353bf rstam committed Apr 1, 2013
@@ -275,6 +275,10 @@ public void LoadFrom(Stream stream, int count)
while (count > 0)
{
var bytesRead = stream.Read(_bytes, _sliceOffset + position, count);
+ if (bytesRead == 0)
+ {
+ throw new EndOfStreamException();
+ }
position += bytesRead;
count -= bytesRead;
}
@@ -78,6 +78,10 @@ public static IByteBuffer LoadFrom(Stream stream)
while (count > 0)
{
var bytesRead = stream.Read(lengthBytes, offset, count);
+ if (bytesRead == 0)
+ {
+ throw new EndOfStreamException();
+ }
offset += bytesRead;
count -= bytesRead;
}
@@ -351,6 +351,10 @@ public void LoadFrom(Stream stream, int count)
var chunkRemaining = _chunkSize - chunkOffset;
var bytesToRead = (count <= chunkRemaining) ? count : chunkRemaining;
var bytesRead = stream.Read(_chunks[chunkIndex].Bytes, chunkOffset, bytesToRead);
+ if (bytesRead == 0)
+ {
+ throw new EndOfStreamException();
+ }
position += bytesRead;
count -= bytesRead;
}

0 comments on commit 92b8bde

Please sign in to comment.