Skip to content

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

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

flub
Copy link
Contributor

@flub flub commented Jan 7, 2025

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

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

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
@flub flub requested a review from a team January 7, 2025 13:54
@flub
Copy link
Contributor Author

flub commented Jan 7, 2025

cc @arilotter

Copy link

github-actions bot commented Jan 7, 2025

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

Copy link

github-actions bot commented Jan 7, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: ff245cd

@@ -289,7 +288,7 @@ impl RouterBuilder {
// handle incoming p2p connections.
incoming = endpoint.accept() => {
let Some(incoming) = incoming else {
break;
break; // Endpoint is closed.
Copy link
Contributor

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?

Copy link
Member

@matheus23 matheus23 Jan 7, 2025

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.

Copy link
Contributor Author

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?

@flub flub added this pull request to the merge queue Jan 8, 2025
Merged via the queue into main with commit 9cef520 Jan 8, 2025
29 checks passed
@flub flub deleted the flub/endpoint-no-cancellation-token branch May 14, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

consider making Endpoint::cancel_token public
3 participants