-
Notifications
You must be signed in to change notification settings - Fork 235
refactor(iroh): Remove CancellationToken from Endpoint #3101
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
Conversation
The internal CancellationToke was used to know by other parts of the code when the endpoint is shut down. But those bits of code already have mechanisms to do so. This bit of API makes is a bit of extra complexity that is not needed. Closes #3096
cc @arilotter |
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3101/docs/iroh/ Last updated: 2025-01-07T13:55:40Z |
@@ -289,7 +288,7 @@ impl RouterBuilder { | |||
// handle incoming p2p connections. | |||
incoming = endpoint.accept() => { | |||
let Some(incoming) = incoming else { | |||
break; | |||
break; // Endpoint is closed. |
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.
do we need to cancel the token 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.
Good point, but we should probably cancel the token around the shutdown(&endpoint, protocols).await
line.
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.
Line 257 above makes a drop guard from the cancel_token. Isn't that sufficient? Or do we think this is being dropped too late?
Description
The internal CancellationToke was used to know by other parts of the
code when the endpoint is shut down. But those bits of code already
have mechanisms to do so. This bit of API makes is a bit of extra
complexity that is not needed.
Breaking Changes
None, this is internal.
Notes & open questions
Closes #3096.
Closes #3098 (replaces).
Maybe not directly but now there's an example of how to write an
accept loop without having to rely on the CancellationToken.
Change checklist