Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 92b8bde6932fa47ab1edb69b9cdb70386c6353bf 1 parent 2b69d85
rstam authored
View
4 MongoDB.Bson/IO/ByteArrayBuffer.cs
@@ -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;
}
View
4 MongoDB.Bson/IO/ByteBufferFactory.cs
@@ -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;
}
View
4 MongoDB.Bson/IO/MultiChunkBuffer.cs
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.