From 31c0ca846c4a62bf9f9ab4f4db702493983a5397 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 23 Feb 2015 18:32:23 -0600 Subject: [PATCH] Release lock during bad connection attempts Release the lock which would normally be released as part of a callback if the call is made synchronously by invoking the delegate on the ThreadPool. This code likely needs more attention as it's quite convoluted. --- src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs | 6 +++--- src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs b/src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs index 85540510bca..38e5af8986d 100644 --- a/src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs +++ b/src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs @@ -33,12 +33,12 @@ internal class TcpConnection : TcpConnectionBase, ITcpConnection { connection.InitSocket(socket); if (onConnectionEstablished != null) - onConnectionEstablished(connection); + ThreadPool.QueueUserWorkItem(o => onConnectionEstablished(connection)); }, (_, socketError) => { if (onConnectionFailed != null) - onConnectionFailed(connection, socketError); + ThreadPool.QueueUserWorkItem(o => onConnectionFailed(connection, socketError)); }, connection, connectionTimeout); // ReSharper restore ImplicitlyCapturedClosure return connection; @@ -356,4 +356,4 @@ public override string ToString() return RemoteEndPoint.ToString(); } } -} \ No newline at end of file +} diff --git a/src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs b/src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs index 048e222e6fe..92b9a67aa87 100644 --- a/src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs +++ b/src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs @@ -33,12 +33,12 @@ internal class TcpConnectionSsl : TcpConnectionBase, ITcpConnection { connection.InitClientSocket(socket, targetHost, validateServer); if (onConnectionEstablished != null) - onConnectionEstablished(connection); + ThreadPool.QueueUserWorkItem(o => onConnectionEstablished(connection)); }, (_, socketError) => { if (onConnectionFailed != null) - onConnectionFailed(connection, socketError); + ThreadPool.QueueUserWorkItem(o => onConnectionFailed(connection, socketError)); }, connection, connectionTimeout); // ReSharper restore ImplicitlyCapturedClosure return connection; @@ -434,4 +434,4 @@ public override string ToString() return "S" + RemoteEndPoint; } } -} \ No newline at end of file +}