-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cancelability of DNS queries #104420
Fix cancelability of DNS queries #104420
Conversation
@rokonec just to make 100% sure this actually works, I wonder what is the output of this program (or equivalent test case) before/after the change on Windows? using Socket socket = new(SocketType.Stream, ProtocolType.Tcp);
Stopwatch sw = Stopwatch.StartNew();
try
{
await socket.ConnectAsync(new DnsEndPoint("does-not-exist", 80), new CancellationTokenSource(500).Token);
}
catch (OperationCanceledException)
{
Console.WriteLine(sw.ElapsedMilliseconds);
} I wish we could turn this into a test-case, but unfortunately it would flake in CI. |
@antonfirsov Good hunch .. it was indeed NOT working properly. It was throwing wrong exception. After the fix in 5e25367 it all seems to be working fine. Please check those changes. Before
After
|
…m/rokonec/runtime into dev/rokonec/socket-ct-propagation
/azp run runtime |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for 5e25367. Would be still good to have a third pair of eyes taking a look on the whole thing.
@rokonec since the change is not immediately trivial from the first look, can you update the PR description with an explanation (1) why do these two changes fix the thing (2) why don't they impact other code paths negatively? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM, is it possible to add a test case for this?
Do we have any way to slow down the DNS resolving?
/cc @antonfirsov
This but I doubt this approach is reliable on CI. To make things robust, we would need to dockerize a custom environment config. |
/ba-g Known issues or unrelated tests |
Fixes: #92054
Context
ConnectAsync(EndPoint, CancellationToken)
had not configured downstream code to propagate cancelation to DNS queries.Changes made
Instruct related
AwaitableSocketAsyncEventArgs
to be cancelable - authored by @antonfirsov in #92862saeaCancelable: false
which makes it uncancelable. Configuring it by abilities of used CT maked it work as intended.Propagate cancelation during connect by name (5e25367)