From d7b5f4f6d6e2271014a51ec0d4e76016f60b38f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Sun, 5 May 2024 18:38:08 +0200 Subject: [PATCH] Exlicitly drop packet router when shutdown detected In the vpn client I've observed that 2 out of 3 times the disconnect procedure stalls out. Investigating in the logs these 5 are still running when we hit shutdown timeout. [TaskClient-nym_vpn_lib-mixnet_client_main-real_traffic_controller-ack_control-retransmission_request_listener] Polling shutdown failed: channel closed [TaskClient-nym_vpn_lib-mixnet_client_main-real_traffic_controller-out_queue_control] Polling shutdown failed: channel closed [TaskClient-gateway-packet-router] Polling shutdown failed: channel closed [TaskClient-nym_vpn_lib-mixnet_client_main-gateway_transceiver] Polling shutdown failed: channel closed [TaskClient-nym_vpn_lib-mixnet_client_main-mix_traffic_controller] Polling shutdown failed: channel closed I _think_ what was causing the problem here is that the task client in the packet router is not being awaited in an event loop like other client instances. Explictly drop it in the socket state to make sure it's not blocking shutdown. --- common/client-libs/gateway-client/src/socket_state.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/client-libs/gateway-client/src/socket_state.rs b/common/client-libs/gateway-client/src/socket_state.rs index 386ad5b147..2e3f096b3f 100644 --- a/common/client-libs/gateway-client/src/socket_state.rs +++ b/common/client-libs/gateway-client/src/socket_state.rs @@ -158,6 +158,9 @@ impl PartiallyDelegated { _ = shutdown.recv() => { log::trace!("GatewayClient listener: Received shutdown"); log::debug!("GatewayClient listener: Exiting"); + // The packet router a task client, and as such we need to make + // sure it's dropped to not stall the shutdown process. + drop(packet_router); return; } _ = &mut notify_receiver => {