Commit 6eb9ee9b authored by Marc Gravell's avatar Marc Gravell

Improve error message when a connection fails

parent 5214df34
syntax: glob syntax: glob
*/bin/ */bin/
.git
*/obj/ */obj/
Tests/bin/ Tests/bin/
Tests/obj/ Tests/obj/
......
...@@ -36,6 +36,6 @@ public enum ConnectionFailureType ...@@ -36,6 +36,6 @@ public enum ConnectionFailureType
/// <summary> /// <summary>
/// The socket was closed /// The socket was closed
/// </summary> /// </summary>
ConnectionDisposed ConnectionDisposed,
} }
} }
...@@ -129,10 +129,11 @@ public void Dispose() ...@@ -129,10 +129,11 @@ public void Dispose()
} }
OnCloseEcho(); OnCloseEcho();
} }
long lastWriteTickCount, lastReadTickCount;
public void Flush() public void Flush()
{ {
outStream.Flush(); outStream.Flush();
Interlocked.Exchange(ref lastWriteTickCount, Environment.TickCount);
} }
int failureReported; int failureReported;
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null) public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null)
...@@ -146,7 +147,11 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception ...@@ -146,7 +147,11 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
{ {
try try
{ {
string message = failureType + " on " + Format.ToString(bridge.ServerEndPoint.EndPoint) + "/" + connectionType; long now = Environment.TickCount, lastRead = Interlocked.Read(ref lastReadTickCount), lastWrite = Interlocked.Read(ref lastWriteTickCount);
string message = failureType + " on " + Format.ToString(bridge.ServerEndPoint.EndPoint) + "/" + connectionType
+ ", input-butter: " + ioBufferBytes + ", outstanding: " + GetOutstandingCount()
+ ", last-read: " + (now - lastRead) / 1000 + "s ago, last-write" + (now - lastWrite) / 1000 + "s ago";
var ex = innerException == null var ex = innerException == null
? new RedisConnectionException(failureType, message) ? new RedisConnectionException(failureType, message)
: new RedisConnectionException(failureType, message, innerException); : new RedisConnectionException(failureType, message, innerException);
...@@ -623,6 +628,7 @@ private void ProcessBytes(int bytesRead) ...@@ -623,6 +628,7 @@ private void ProcessBytes(int bytesRead)
} }
else else
{ {
Interlocked.Exchange(ref lastReadTickCount, Environment.TickCount);
ioBufferBytes += bytesRead; ioBufferBytes += bytesRead;
multiplexer.Trace("More bytes available: " + bytesRead + " (" + ioBufferBytes + ")", physicalName); multiplexer.Trace("More bytes available: " + bytesRead + " (" + ioBufferBytes + ")", physicalName);
int offset = 0, count = ioBufferBytes; int offset = 0, count = ioBufferBytes;
......
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