From ebb75bc399ab4be26b3f2bcbf3bcb98fa369ccdd Mon Sep 17 00:00:00 2001 From: xinchen Date: Fri, 18 Sep 2020 15:40:19 -0700 Subject: [PATCH] Close socket if connection already timed out. --- .../Amqp/Transport/TcpTransportInitiator.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs b/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs index 3b81ea99..4234cf70 100644 --- a/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs +++ b/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs @@ -64,6 +64,10 @@ static void OnConnectComplete(object sender, SocketAsyncEventArgs e) { thisPtr.Complete(e, false); } + else + { + e.ConnectSocket?.Dispose(); + } } static void OnTimer(object obj) @@ -83,9 +87,9 @@ void Complete(SocketAsyncEventArgs e, bool completeSynchronously) if (e.SocketError != SocketError.Success) { exception = new SocketException((int)e.SocketError); - if (e.AcceptSocket != null) + if (e.ConnectSocket != null) { - e.AcceptSocket.Dispose(); + e.ConnectSocket.Dispose(); } } else