Commit 9426e1af authored by Marc Gravell's avatar Marc Gravell

add the SocketConnection ShutdownKind/SocketError to the failure outputl make...

add the SocketConnection ShutdownKind/SocketError to the failure outputl make Roslynator happy in a bunch of places
parent a52077c2
...@@ -125,7 +125,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include ...@@ -125,7 +125,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include
internal static Exception PopulateInnerExceptions(ReadOnlySpan<ServerEndPoint> serverSnapshot) internal static Exception PopulateInnerExceptions(ReadOnlySpan<ServerEndPoint> serverSnapshot)
{ {
var innerExceptions = new List<Exception>(); var innerExceptions = new List<Exception>();
if (serverSnapshot.Length > 0 && serverSnapshot[0].Multiplexer.LastException != null) if (serverSnapshot.Length > 0 && serverSnapshot[0].Multiplexer.LastException != null)
{ {
innerExceptions.Add(serverSnapshot[0].Multiplexer.LastException); innerExceptions.Add(serverSnapshot[0].Multiplexer.LastException);
...@@ -195,10 +195,6 @@ private static string GetLabel(bool includeDetail, RedisCommand command, Message ...@@ -195,10 +195,6 @@ private static string GetLabel(bool includeDetail, RedisCommand command, Message
return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.Command.ToString()); return message == null ? command.ToString() : (includeDetail ? message.CommandAndKey : message.Command.ToString());
} }
private static string GetLabel(bool includeDetail, string command, Message message)
{
return message == null ? command : (includeDetail ? message.CommandAndKey : message.Command.ToString());
}
internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string failureMessage=null) internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string failureMessage=null)
{ {
var sb = new StringBuilder("It was not possible to connect to the redis server(s)."); var sb = new StringBuilder("It was not possible to connect to the redis server(s).");
......
...@@ -275,7 +275,8 @@ public Task FlushAsync() ...@@ -275,7 +275,8 @@ public Task FlushAsync()
return Task.CompletedTask; return Task.CompletedTask;
} }
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null, bool isInitialConnect = false) public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null,
bool isInitialConnect = false, IDuplexPipe connectingPipe = null)
{ {
Exception outerException = innerException; Exception outerException = innerException;
IdentifyFailureType(innerException, ref failureType); IdentifyFailureType(innerException, ref failureType);
...@@ -307,6 +308,16 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception ...@@ -307,6 +308,16 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
var exMessage = new StringBuilder(failureType.ToString()); var exMessage = new StringBuilder(failureType.ToString());
if ((connectingPipe ?? _ioPipe) is SocketConnection sc)
{
exMessage.Append(" (").Append(sc.ShutdownKind);
if (sc.SocketError != SocketError.Success)
{
exMessage.Append("/").Append(sc.SocketError);
}
exMessage.Append(")");
}
var data = new List<Tuple<string, string>>(); var data = new List<Tuple<string, string>>();
if (IncludeDetailInExceptions) if (IncludeDetailInExceptions)
{ {
...@@ -1082,6 +1093,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc ...@@ -1082,6 +1093,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
var bridge = BridgeCouldBeNull; var bridge = BridgeCouldBeNull;
if (bridge == null) return false; if (bridge == null) return false;
IDuplexPipe pipe = null;
try try
{ {
// disallow connection in some cases // disallow connection in some cases
...@@ -1093,7 +1105,6 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc ...@@ -1093,7 +1105,6 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
var config = bridge.Multiplexer.RawConfig; var config = bridge.Multiplexer.RawConfig;
IDuplexPipe pipe;
if (config.Ssl) if (config.Ssl)
{ {
bridge.Multiplexer.LogLocked(log, "Configuring SSL"); bridge.Multiplexer.LogLocked(log, "Configuring SSL");
...@@ -1141,7 +1152,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc ...@@ -1141,7 +1152,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
} }
catch (Exception ex) catch (Exception ex)
{ {
RecordConnectionFailed(ConnectionFailureType.InternalFailure, ex, isInitialConnect: true); // includes a bridge.OnDisconnected RecordConnectionFailed(ConnectionFailureType.InternalFailure, ex, isInitialConnect: true, connectingPipe: pipe); // includes a bridge.OnDisconnected
bridge.Multiplexer.Trace("Could not connect: " + ex.Message, physicalName); bridge.Multiplexer.Trace("Could not connect: " + ex.Message, physicalName);
return false; return false;
} }
......
...@@ -1737,7 +1737,7 @@ protected NameValueEntry[] ParseStreamEntryValues(RawResult result) ...@@ -1737,7 +1737,7 @@ protected NameValueEntry[] ParseStreamEntryValues(RawResult result)
} }
var arr = result.GetItems(); var arr = result.GetItems();
// Calculate how many name/value pairs are in the stream entry. // Calculate how many name/value pairs are in the stream entry.
int count = arr.Length / 2; int count = arr.Length / 2;
......
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