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

Improve error message when a connection fails

parent 5214df34
syntax: glob
*/bin/
.git
*/obj/
Tests/bin/
Tests/obj/
......
......@@ -36,6 +36,6 @@ public enum ConnectionFailureType
/// <summary>
/// The socket was closed
/// </summary>
ConnectionDisposed
ConnectionDisposed,
}
}
......@@ -129,10 +129,11 @@ public void Dispose()
}
OnCloseEcho();
}
long lastWriteTickCount, lastReadTickCount;
public void Flush()
{
outStream.Flush();
Interlocked.Exchange(ref lastWriteTickCount, Environment.TickCount);
}
int failureReported;
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null)
......@@ -146,7 +147,11 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
{
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
? new RedisConnectionException(failureType, message)
: new RedisConnectionException(failureType, message, innerException);
......@@ -623,6 +628,7 @@ private void ProcessBytes(int bytesRead)
}
else
{
Interlocked.Exchange(ref lastReadTickCount, Environment.TickCount);
ioBufferBytes += bytesRead;
multiplexer.Trace("More bytes available: " + bytesRead + " (" + ioBufferBytes + ")", physicalName);
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