未验证 提交 1a94e822 编写于 作者: T Tomas Weinfurt 提交者: GitHub

make CancelConnectAsync thread safe (#42935)

* make CancelConnectAsync thread safe

* replace var with MultipleConnectAsync
上级 036bb72b
......@@ -589,20 +589,16 @@ internal void CancelConnectAsync()
{
if (_operating == InProgress && _completedOperation == SocketAsyncOperation.Connect)
{
if (_multipleConnect != null)
MultipleConnectAsync? multipleConnect = _multipleConnect;
if (multipleConnect != null)
{
// If a multiple connect is in progress, abort it.
_multipleConnect.Cancel();
multipleConnect.Cancel();
}
else
{
// Otherwise we're doing a normal ConnectAsync - cancel it by closing the socket.
// _currentSocket will only be null if _multipleConnect was set, so we don't have to check.
if (_currentSocket == null)
{
NetEventSource.Fail(this, "CurrentSocket and MultipleConnect both null!");
}
_currentSocket.Dispose();
_currentSocket?.Dispose();
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册