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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ impl Endpoint {
///
/// Returns an error if closing the magic socket failed.
/// TODO: Document error cases.
pub async fn close(self, error_code: VarInt, reason: &[u8]) -> Result<()> {
pub async fn close(&self, error_code: VarInt, reason: &[u8]) -> Result<()> {
let Endpoint {
msock,
endpoint,
Expand All @@ -858,9 +858,7 @@ impl Endpoint {
tracing::debug!("Closing connections");
endpoint.close(error_code, reason);
endpoint.wait_idle().await;
// In case this is the last clone of `Endpoint`, dropping the `quinn::Endpoint` will
// make it more likely that the underlying socket is not polled by quinn anymore after this
drop(endpoint);

tracing::debug!("Connections closed");

msock.close().await?;
Expand Down
1 change: 0 additions & 1 deletion iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ impl<D: iroh_blobs::store::Store> NodeInner<D> {
// connections: Operations will immediately fail with ConnectionError::LocallyClosed.
// All streams are interrupted, this is not graceful.
self.endpoint
.clone()
.close(error_code.into(), error_code.reason()),
// Shutdown protocol handlers.
protocols.shutdown(),
Expand Down