From a5125b399844e3eb923fd7ea827a6ecfa3cc4470 Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 14 Oct 2026 18:04:34 +0300 Subject: [PATCH] End the connection's streams as the loop ends, not after the shutdown The ConnectionStreams guard was dropped only after shutdown_connection, which can wait up to three seconds. The loop no longer reads commands once it has broken, so a StreamCmd::Shutdown the session sent in that window never reached the stream task; the task ran on until the guard dropped. Drop the guard right after the loop. The stream task's shutdown needs nothing of the connection (it reports to the session's channels), so nothing relied on the late drop. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/voice.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/voelin-core/src/voice.rs b/crates/voelin-core/src/voice.rs index da0c9c5..729e20c 100644 --- a/crates/voelin-core/src/voice.rs +++ b/crates/voelin-core/src/voice.rs @@ -461,6 +461,11 @@ async fn run_inner( Input::Tick => voice.tick(), } }; + // The streams end now, not after the shutdown below (up to three seconds): + // the commands are not read any more, so a `StreamCmd::Shutdown` the + // session sends from here on would never reach the stream task. Its end + // needs nothing of the connection: it reports to the session's channels. + drop(voice.streams.take()); // Transfers the server never opened fail; running ones go on. for (_, job) in voice.jobs.drain() { job.report()(TransferState::Failed("disconnected".into()));