From e316d994e4e00e0e79809aa3fb89df00de3ce91f Mon Sep 17 00:00:00 2001 From: Henauxg <19689618+Henauxg@users.noreply.github.com> Date: Mon, 16 Jan 2023 19:44:51 +0100 Subject: [client & server] Close waiter: only signal connection closed if the internal channel still exists --- src/client.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index 6416395..6b63b29 100644 --- a/src/client.rs +++ b/src/client.rs @@ -611,10 +611,13 @@ async fn connection_task(spawn_config: ConnectionSpawnConfig) { tokio::spawn(async move { let conn_err = conn.closed().await; info!("Disconnected: {}", conn_err); - to_sync_client - .send(ClientAsyncMessage::ConnectionClosed(conn_err)) - .await - .expect("Failed to signal connection lost to sync client"); + // If we requested the connection to close, channel may have been closed already. + if !to_sync_client.is_closed() { + to_sync_client + .send(ClientAsyncMessage::ConnectionClosed(conn_err)) + .await + .expect("Failed to signal connection lost to sync client"); + } }) }; -- cgit v1.2.3