Skip to content

Commit

Permalink
Release lock during bad connection attempts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jen20 committed Mar 7, 2015
1 parent a281b10 commit 31c0ca8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/EventStore.ClientAPI/Transport.Tcp/TcpConnection.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -356,4 +356,4 @@ public override string ToString()
return RemoteEndPoint.ToString();
}
}
}
}
6 changes: 3 additions & 3 deletions src/EventStore.ClientAPI/Transport.Tcp/TcpConnectionSsl.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -434,4 +434,4 @@ public override string ToString()
return "S" + RemoteEndPoint;
}
}
}
}

0 comments on commit 31c0ca8

Please sign in to comment.