Commit b4766acb authored by Marc Gravell's avatar Marc Gravell

Merge pull request #71 from deepakverma/master

Cannot access a disposed object when auth fails Issue #50 and connection fails to reconnect with retry when cache is under load #65
parents 02ae9601 525b188d
...@@ -1060,7 +1060,8 @@ public void GetStatus(TextWriter log) ...@@ -1060,7 +1060,8 @@ public void GetStatus(TextWriter log)
internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, TextWriter log, EndPoint blame, string cause) internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, TextWriter log, EndPoint blame, string cause)
{ {
if (isDisposed) throw new ObjectDisposedException(ToString()); if (isDisposed) throw new ObjectDisposedException(ToString());
//if connection failed treat it as first to honor retry logic.
first = cause.CompareTo("connection failed") == 0 ? true : first;
bool showStats = true; bool showStats = true;
if (log == null) if (log == null)
{ {
...@@ -1119,7 +1120,6 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text ...@@ -1119,7 +1120,6 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
} }
} }
} }
int attemptsLeft = first ? configuration.ConnectRetry : 1; int attemptsLeft = first ? configuration.ConnectRetry : 1;
bool healthy = false; bool healthy = false;
......
...@@ -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