From 479cb956f11383e894ac03a48b4db7520949ae2b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 24 Jun 2022 10:28:04 +0200 Subject: [PATCH] If we are running out of descriptors, drop an old connection and wait --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index ac5f98e..dde1a7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -292,6 +292,10 @@ async fn tcp_acceptor(globals: Arc, tcp_listener: TcpListener) -> Resul continue; } warn!("TCP accept error: {}", e); + if let Some(tx_oldest) = active_connections.lock().pop_back() { + let _ = tx_oldest.send(()); + } + tokio::time::sleep(Duration::from_secs(1)).await; continue; } };