Skip to content
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

p2p/nat: limit UPNP request concurrency #21390

Merged
merged 4 commits into from
Aug 5, 2020

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Jul 30, 2020

This adds a lock around requests because some routers can't handle
concurrent requests.

Fixes #21370

@fjl fjl requested a review from zsfelfoldi as a code owner July 30, 2020 16:24
@fjl fjl changed the title p2p/nat: limit UPNP request concurrency WIP p2p/nat: limit UPNP request concurrency Aug 1, 2020
fjl added 2 commits August 3, 2020 20:13
This change makes Map request a new mapping exactly when the
map timeout occurs instead of 5 minutes earlier.
@fjl fjl mentioned this pull request Aug 3, 2020
@fjl fjl changed the title WIP p2p/nat: limit UPNP request concurrency p2p/nat: limit UPNP request concurrency Aug 3, 2020
Copy link
Contributor

@zsfelfoldi zsfelfoldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments but otherwise LGTM

if lastreq < rateLimit {
time.Sleep(rateLimit - lastreq)
}
err := fn()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you passing through an error result here? The input params and the rest of the results are passed through the caller's local context, it just feels illogical to pass an error result here when you are not doing anything else with it. It could be a simple fn func().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sometimes the only result is an error. If you still prefer it this way then I am fine with it, it just gave me a wrong first impression that the error result might have a special meaning to the rate limiter function.

@fjl fjl merged commit 1d25039 into ethereum:master Aug 5, 2020
@fjl fjl added this to the 1.9.19 milestone Aug 5, 2020
@fjl fjl removed the status:triage label Aug 5, 2020
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
This adds a lock around requests because some routers can't handle
concurrent requests. Requests are also rate-limited.
 
The Map function request a new mapping exactly when the map timeout
occurs instead of 5 minutes earlier. This should prevent duplicate mappings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UPnP does not work
2 participants