From 8cb16fc39d5f53a4ea9d39970e4bd76b9ef82dc3 Mon Sep 17 00:00:00 2001 From: iacore Date: Sun, 3 Nov 2024 20:31:02 +0000 Subject: [PATCH] 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?;