-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
Conversation
This change makes Map request a new mapping exactly when the map timeout occurs instead of 5 minutes earlier.
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.
See my comments but otherwise LGTM
if lastreq < rateLimit { | ||
time.Sleep(rateLimit - lastreq) | ||
} | ||
err := fn() |
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.
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()
.
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.
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.
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.
This adds a lock around requests because some routers can't handle
concurrent requests.
Fixes #21370