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

ref(iroh-net)!: Make Endpoint::close not consume self #2882

Merged
merged 4 commits into from
Nov 27, 2024

Conversation

iacore
Copy link
Contributor

@iacore iacore commented Nov 3, 2024

Description

The endpoint can be freely cloned, so consuming self on shutdown is somewhat fruitless. This changes it to take &self like a normal method.

Breaking Changes

  • Endpoint::close now takes &self rather than self. This can in some situations mean an existing (clone of an) endpoint might be dropped too early as a temporary variable.

Notes & open questions

Change checklist

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

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

This needs to get the changes in main, and then check if the new doc comment needs tweaking because we need to make it clear how this works. But in general I think this is probably a good change.

@flub flub added the c-iroh label Nov 5, 2024
Co-authored-by: Floris Bruynooghe <[email protected]>
Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

LGTM to me, but would love @divagant-martian to lgtm too (or not)

@divagant-martian
Copy link
Contributor

divagant-martian commented Nov 12, 2024

this was in part because of how quinn used to work. Closing the magic socket before dropping the endpoint would basically always emit an error in logs breaking all our cli tests. The changes in the endpoint loop make this less likely to happen in this scenario. This is not to say the previous state was exactly what we needed: As the comment mentions, it's there to make it less likely that the socket is polled. In general closing here is messy and kinda gross. When we wrote this code (not sure now) the socket was the last resource the (quinn) endpoint dropped. This was later that the drop of the endpoint itself given the many cloned Arcs and spawned tasks.

All this long rant is to say: there was a reason this looked this way. To get a best effort imperfect close because both how quinn works and the lack of async drop (and I thought the rant was over) but after we updated quinn I think the error is no longer an issue and we are fine with dropping the endpoint after the socket in most cases

@flub flub changed the title Make Endpoint::close not consuming self ref(iroh-net): Make Endpoint::close not consume self Nov 27, 2024
@flub flub changed the title ref(iroh-net): Make Endpoint::close not consume self ref(iroh-net)!: Make Endpoint::close not consume self Nov 27, 2024
@flub flub added this pull request to the merge queue Nov 27, 2024
@flub
Copy link
Contributor

flub commented Nov 27, 2024

Thanks @iacore for pushing this change!

Merged via the queue into n0-computer:main with commit 50f66dd Nov 27, 2024
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants