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). |
antonfirsov
left a comment
There was a problem hiding this comment.
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? |
liveans
left a comment
There was a problem hiding this comment.
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
AwaitableSocketAsyncEventArgsto be cancelable - authored by @antonfirsov in #92862saeaCancelable: falsewhich makes it uncancelable. Configuring it by abilities of used CT maked it work as intended.Propagate cancelation during connect by name (5e25367)