From 8cb16fc39d5f53a4ea9d39970e4bd76b9ef82dc3 Mon Sep 17 00:00:00 2001 From: iacore Date: Sun, 3 Nov 2024 20:31:02 +0000 Subject: [PATCH 1/3] Make Endpoint::close not owning --- iroh-net/src/endpoint.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/iroh-net/src/endpoint.rs b/iroh-net/src/endpoint.rs index 4eb7b978ae..f9259b047f 100644 --- a/iroh-net/src/endpoint.rs +++ b/iroh-net/src/endpoint.rs @@ -847,20 +847,18 @@ 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, cancel_token, .. - } = self; + } = &self; cancel_token.cancel(); 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?; From 30fa2de881a606d0f7a82769d144231f502625f9 Mon Sep 17 00:00:00 2001 From: iacore Date: Mon, 4 Nov 2024 12:24:49 +0000 Subject: [PATCH 2/3] Fix usage --- iroh/src/node.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/iroh/src/node.rs b/iroh/src/node.rs index 8e1c83b736..f67815c833 100644 --- a/iroh/src/node.rs +++ b/iroh/src/node.rs @@ -465,7 +465,6 @@ impl NodeInner { // 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(), From 2dfc33e4250e3cc384de62e7cb878b837ed00511 Mon Sep 17 00:00:00 2001 From: iacore <74560659+iacore@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:43:34 +0000 Subject: [PATCH 3/3] Update iroh-net/src/endpoint.rs Co-authored-by: Floris Bruynooghe --- iroh-net/src/endpoint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iroh-net/src/endpoint.rs b/iroh-net/src/endpoint.rs index f9259b047f..7c7cc94ea7 100644 --- a/iroh-net/src/endpoint.rs +++ b/iroh-net/src/endpoint.rs @@ -853,7 +853,7 @@ impl Endpoint { endpoint, cancel_token, .. - } = &self; + } = self; cancel_token.cancel(); tracing::debug!("Closing connections"); endpoint.close(error_code, reason);