-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Added Endpoint::reject_new_connections #1585
Conversation
Closes quinn-rs#1584 This commit adds a new function that refuses new connections without impacting existing connections. Internally, this just sets the connection limit to 0, which causes incoming connections to be rejected. This is the same approach that was taken in 0.8.5 when `Incoming` was dropped.
Thanks for the PR! Have you tried instead using the existing |
@Ralith maybe we can pass a |
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.
Since this is an important API for certain graceful shutdown patterns, including it probably makes sense for discoverability.
That doesn't seem very discoverable either, TBH. After discussion I think this is fine. |
These changes address the comments on the pull request.
/// zero. | ||
pub fn reject_new_connections(&mut self) { | ||
if let Some(config) = self.server_config.as_mut() { | ||
Arc::make_mut(config).concurrent_connections(0); |
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.
Should this me Arc::make_mut
and also handle a case where the value is used concurrently more explicitly? I don't think clone-on-write is really what's meant here...
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.
For the purposes of this code, it seems sufficient to me that self.server_config
holds the modified config. Seems to me that we don't really care that Connection
s are holding on to a "stale" ServerConfig
that still allows more concurrent_connections
.
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 misread what Arc::make_mut
actually does. Yeah, this design is good!
This commit adds a new function that refuses new connections without impacting existing connections. Internally, this just sets the connection limit to 0, which causes incoming connections to be rejected. This is the same approach that was taken in 0.8.5 when `Incoming` was dropped.
This commit adds a new function that refuses new connections without impacting existing connections. Internally, this just sets the connection limit to 0, which causes incoming connections to be rejected. This is the same approach that was taken in 0.8.5 when `Incoming` was dropped.
Closes #1584
This commit adds a new function that refuses new connections without impacting existing connections. Internally, this just sets the connection limit to 0, which causes incoming connections to be rejected. This is the same approach that was taken in 0.8.5 when
Incoming
was dropped.Let me know if I should also add a unit test to the
quinn
crate. Since it's a simple pass-through, I elected not to initially.