From: Dietmar Maurer Date: Wed, 4 Nov 2020 07:49:35 +0000 (+0100) Subject: proxy: log if there are too many open connections X-Git-Tag: v0.9.6~16 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ea93bea7bf3b4b0c35409c006424da68e077a9a1;p=proxmox-backup.git proxy: log if there are too many open connections --- diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 42dfc11a..4fef4274 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -167,11 +167,11 @@ fn accept_connections( debug: bool, ) -> tokio::sync::mpsc::Receiver, Error>> { - let (sender, receiver) = tokio::sync::mpsc::channel(1024); + const MAX_PENDING_ACCEPTS: usize = 1024; - let accept_counter = Arc::new(()); + let (sender, receiver) = tokio::sync::mpsc::channel(MAX_PENDING_ACCEPTS); - const MAX_PENDING_ACCEPTS: usize = 1024; + let accept_counter = Arc::new(()); tokio::spawn(async move { loop { @@ -186,9 +186,7 @@ fn accept_connections( let mut sender = sender.clone(); if Arc::strong_count(&accept_counter) > MAX_PENDING_ACCEPTS { - if debug { - eprintln!("connection rejected - to many open connections"); - } + eprintln!("connection rejected - to many open connections"); continue; }