diff --git a/proxy/src/main.rs b/proxy/src/main.rs index 90def5e..53f69db 100644 --- a/proxy/src/main.rs +++ b/proxy/src/main.rs @@ -335,19 +335,13 @@ async fn connect_proxy_impl( info!("connected to Mumble server"); - // Spawn tasks to handle transmitting data between the WebTransport client and Mumble TCP Server - let c2s = tokio::spawn( - pass_bytes_loop(incoming, write_server) - .instrument(info_span!("Handler", "Client to server")), - ); - let s2c = tokio::spawn( - pass_bytes_loop(read_server, outgoing) - .instrument(info_span!("Handler", "Server to client")), - ); - + // Handle transmitting data between the WebTransport client and Mumble TCP Server + // When one direction completes/fails, the other is dropped and its streams are closed tokio::select! { - res = c2s => res??, - res = s2c => res??, + res = pass_bytes_loop(incoming, write_server) + .instrument(info_span!("Handler", "Client to server")) => res?, + res = pass_bytes_loop(read_server, outgoing) + .instrument(info_span!("Handler", "Server to client")) => res?, }; Ok(()) }