Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Serialize Dns async-over-sync requests for the same host#49171

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
stephentoub merged 2 commits intodotnet:mainfromstephentoub:coalescedns2
Mar 5, 2021

Conversation

@stephentoub
Copy link
Member

davidfowl reacted with thumbs up emoji
@ghostghost added the area-System.Net labelMar 4, 2021
@ghost
Copy link

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes#48566
cc:@geoffkizer,@davidfowl

Author:stephentoub
Assignees:-
Labels:

area-System.Net

Milestone:-

@davidfowl
Copy link
Member

@sebastienros I think we should do proxy test run here (httpclient and YARP).

@geoffkizer
Copy link
Contributor

Could the code here be simplified using a semaphore per hostname?

@stephentoub
Copy link
MemberAuthor

That's basically what this is: "waiting on the semaphore" is done by waiting on the task currently holding the baton.

If you mean actually having a SemaphoreSlim, for example, when is it removed from the dictionary to avoid a potential leak?

@geoffkizer
Copy link
Contributor

If you mean actually having a SemaphoreSlim,

Yeah, that's what I meant.

when is it removed from the dictionary to avoid a potential leak?

Ref count it under the lock.

@stephentoub
Copy link
MemberAuthor

Ref count it under the lock.

How does that look different from what I have here? At that point, you're retrieving a semaphore instead of a task from the dictionary, and waiting on semaphore.WaitAsync instead of task, but then also needing to call semaphore.Release()?

@geoffkizer
Copy link
Contributor

How does that look different from what I have here?

It's probably not all that different; it mainly avoids using stuff like ContinueWith. For me, at least, I find it much easier to reason about simple awaits than to reason about ContinueWith, especially when you add stuff like TaskContinuationOptions.ExecuteSynchronously. I've gotten burned here in the past, so now my instinct is to try to avoid doing this if I can.

But it's not a big deal either way.

@stephentoub
Copy link
MemberAuthor

It doesn't really avoid it :) In order to be able to support the task getting canceled, you need to be able to do work after the task completes rather than as part of the task. That means either ContinueWith or a separate async method in which we await. I chose the former. If you would strongly prefer it, I can switch to await; I chose ContinueWith because the common case is that cancellation doesn't happen, and with ContinueWith, I can specify OnlyOnCanceled and avoid the continuation in the common case.

@geoffkizer
Copy link
Contributor

It doesn't really avoid it :) In order to be able to support the task getting canceled, you need to be able to do work after the task completes rather than as part of the task. That means either ContinueWith or a separate async method in which we await. I chose the former. If you would strongly prefer it, I can switch to await; I chose ContinueWith because the common case is that cancellation doesn't happen, and with ContinueWith, I can specify OnlyOnCanceled and avoid the continuation in the common case.

Yeah, I understand. And this just makes me wish we optimized async methods better, so we wouldn't have to face that dilemma. But we're not going to fix that today :)

I'm happy with the code as it is.

@davidfowl
Copy link
Member

The only person I accept using ContinueWith is@stephentoub. I've stopped using it myself though 😆

stephentoub reacted with laugh emojigeoffkizer reacted with heart emoji

@stephentoubstephentoub merged commit69f5fdf intodotnet:mainMar 5, 2021
@stephentoubstephentoub deleted the coalescedns2 branchMarch 5, 2021 21:15
@ghostghost locked asresolvedand limited conversation to collaboratorsApr 4, 2021
@karelzkarelz added this to the6.0.0 milestoneMay 20, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@MihaZupanMihaZupanMihaZupan left review comments

@davidfowldavidfowldavidfowl approved these changes

+2 more reviewers

@gfoidlgfoidlgfoidl left review comments

@geoffkizergeoffkizergeoffkizer approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

Reduce the impact of blocking DNS calls on Unix

6 participants

@stephentoub@davidfowl@geoffkizer@gfoidl@MihaZupan@karelz

[8]ページ先頭

©2009-2025 Movatter.jp