mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00
Fix cancelability of DNS queries (#104420)
* Fix cancelability of DNS queries * Properly cascade cancelation info for connect by name exceptions
This commit is contained in:
parent
42b2fc819b
commit
45f3250677
2 changed files with 9 additions and 3 deletions
|
@ -97,7 +97,7 @@ namespace System.Net.Sockets
|
|||
|
||||
saea.RemoteEndPoint = remoteEP;
|
||||
|
||||
ValueTask connectTask = saea.ConnectAsync(this);
|
||||
ValueTask connectTask = saea.ConnectAsync(this, saeaCancelable: cancellationToken.CanBeCanceled);
|
||||
if (connectTask.IsCompleted || !cancellationToken.CanBeCanceled)
|
||||
{
|
||||
// Avoid async invocation overhead
|
||||
|
@ -1210,11 +1210,11 @@ namespace System.Net.Sockets
|
|||
ValueTask.FromException<int>(CreateException(error));
|
||||
}
|
||||
|
||||
public ValueTask ConnectAsync(Socket socket)
|
||||
public ValueTask ConnectAsync(Socket socket, bool saeaCancelable)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (socket.ConnectAsync(this, userSocket: true, saeaCancelable: false))
|
||||
if (socket.ConnectAsync(this, userSocket: true, saeaCancelable: saeaCancelable))
|
||||
{
|
||||
return new ValueTask(this, _mrvtsc.Version);
|
||||
}
|
||||
|
|
|
@ -428,6 +428,12 @@ namespace System.Net.Sockets
|
|||
{
|
||||
_socketError = socketException.SocketErrorCode;
|
||||
}
|
||||
else if (exception is OperationCanceledException)
|
||||
{
|
||||
// Preserve information about the cancellation when it is canceled at non Socket operation.
|
||||
// It is used to throw the right exception later in the stack.
|
||||
_socketError = SocketError.OperationAborted;
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketError = SocketError.SocketError;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue