From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C31A2B4E7 for ; Fri, 29 Apr 2022 11:43:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B2F2696C6 for ; Fri, 29 Apr 2022 11:43:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3E82696BD for ; Fri, 29 Apr 2022 11:43:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 114C34303B for ; Fri, 29 Apr 2022 11:43:10 +0200 (CEST) Date: Fri, 29 Apr 2022 11:43:09 +0200 From: Wolfgang Bumiller To: Dominik Csapak Cc: pbs-devel@lists.proxmox.com Message-ID: <20220429094309.wmygnmjsigvu4pck@wobu-vie.proxmox.com> References: <20220429092017.2410765-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220429092017.2410765-1-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.326 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH] proxmox-backup-proxy: stop accept() loop on daemon shutdown X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2022 09:43:40 -0000 one tiny nit inline On Fri, Apr 29, 2022 at 11:20:17AM +0200, Dominik Csapak wrote: > When a task was running during a reload, the old process would still > accept connections, but drop them due to the closed receiving channel. > > This resulted in sporadic connection failures in such a scenario, > depending on which process got the connection. > > To fix that poll the shutdown_future too during accept, and exit the > loop then. > > Signed-off-by: Dominik Csapak > --- > src/bin/proxmox-backup-proxy.rs | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs > index 744a93f9..b2badfa6 100644 > --- a/src/bin/proxmox-backup-proxy.rs > +++ b/src/bin/proxmox-backup-proxy.rs > @@ -396,12 +396,15 @@ async fn accept_connection( > let accept_counter = Arc::new(()); > > loop { > - let (sock, peer) = match listener.accept().await { > - Ok(conn) => conn, > - Err(err) => { > - eprintln!("error accepting tcp connection: {}", err); > - continue; > - } > + let (sock, peer) = select! { > + res = listener.accept().fuse() => match res { > + Ok(conn) => conn, > + Err(err) => { > + eprintln!("error accepting tcp connection: {}", err); > + continue; > + } > + }, > + _ = proxmox_rest_server::shutdown_future().fuse() => break, I think it would be nicer if we can create the shutdown future once above the loop rather than calling into the `shutdown_future()` fn each iteration. otherwise LGTM