Skip to content

Commit

Permalink
Close socket if connection already timed out.
Browse files Browse the repository at this point in the history
  • Loading branch information
xinchen10 committed Sep 19, 2020
1 parent ebb75bc commit 69fddda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs c
{
if (Interlocked.CompareExchange(ref this.state, 1, 0) == 0)
{
this.Complete(connectEventArgs, true);
this.Complete(this.connectEventArgs, true);
}
else
{
this.connectEventArgs.ConnectSocket?.Dispose();
}

return false;
Expand Down
7 changes: 2 additions & 5 deletions test/TestCases/AmqpTransportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,8 @@ internal static TransportBase AcceptServerTransport(TransportSettings settings)
complete.WaitOne();
complete.Dispose();

transport.Closed += (s, a) =>
{
listener.Close();
Debug.WriteLine("Listeners Closed.");
};
listener.Close();
Debug.WriteLine("Listeners Closed.");

return transport;
}
Expand Down

0 comments on commit 69fddda

Please sign in to comment.