public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH] proxmox-backup-proxy: stop accept() loop on daemon shutdown
Date: Fri, 29 Apr 2022 11:20:17 +0200	[thread overview]
Message-ID: <20220429092017.2410765-1-d.csapak@proxmox.com> (raw)

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 <d.csapak@proxmox.com>
---
 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,
         };
 
         sock.set_nodelay(true).unwrap();
-- 
2.30.2





             reply	other threads:[~2022-04-29  9:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29  9:20 Dominik Csapak [this message]
2022-04-29  9:43 ` Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429092017.2410765-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal