Commit 80b5e3d7 authored by deepakverma's avatar deepakverma

fix #50

parent 02ae9601
...@@ -523,18 +523,25 @@ static void WriteUnified(Stream stream, long value) ...@@ -523,18 +523,25 @@ static void WriteUnified(Stream stream, long value)
void BeginReading() void BeginReading()
{ {
bool keepReading; bool keepReading;
do try
{ {
keepReading = false; do
int space = EnsureSpaceAndComputeBytesToRead();
multiplexer.Trace("Beginning async read...", physicalName);
var result = netStream.BeginRead(ioBuffer, ioBufferBytes, space, endRead, this);
if (result.CompletedSynchronously)
{ {
multiplexer.Trace("Completed synchronously: processing immediately", physicalName); keepReading = false;
keepReading = EndReading(result); int space = EnsureSpaceAndComputeBytesToRead();
} multiplexer.Trace("Beginning async read...", physicalName);
} while (keepReading); var result = netStream.BeginRead(ioBuffer, ioBufferBytes, space, endRead, this);
if (result.CompletedSynchronously)
{
multiplexer.Trace("Completed synchronously: processing immediately", physicalName);
keepReading = EndReading(result);
}
} while (keepReading);
}
catch(System.IO.IOException ex)
{
multiplexer.Trace("Could not connect: " + ex.Message, physicalName);
}
} }
int haveReader; int haveReader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment