From 4d300eb12a45712c382b23532eddf8565cbafd28 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 31 Jul 2024 07:48:13 +1200 Subject: [PATCH] Dont drop half of the TCP stream before dropping the whole thing --- src/bin/chorus.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/chorus.rs b/src/bin/chorus.rs index 553b638..57f4026 100644 --- a/src/bin/chorus.rs +++ b/src/bin/chorus.rs @@ -8,7 +8,6 @@ use std::fs::OpenOptions; use std::io::Read; use std::sync::atomic::Ordering; use std::time::Duration; -use tokio::io::AsyncWriteExt; use tokio::net::TcpListener; use tokio::signal::unix::{signal, SignalKind}; @@ -87,7 +86,7 @@ async fn main() -> Result<(), Error> { // Accepts network connections and spawn a task to serve each one v = listener.accept() => { - let (mut tcp_stream, hashed_peer) = { + let (tcp_stream, hashed_peer) = { let (tcp_stream, peer_addr) = v?; let hashed_peer = HashedPeer::new(peer_addr); (tcp_stream, hashed_peer) @@ -103,7 +102,8 @@ async fn main() -> Result<(), Error> { "{}: Blocking reconnection until {}", hashed_peer.ip(), ip_data.ban_until); - let _ = tcp_stream.shutdown().await; + // note: no need to shutdown() which only drops the write half. + // the whole thing gets dropped when we continue. continue; } }