all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH v2] proxmox-backup-proxy: stop accept() loop on daemon shutdown
@ 2022-04-29 10:04 Dominik Csapak
  2022-05-02 12:21 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2022-04-29 10:04 UTC (permalink / raw)
  To: pbs-devel

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>
---
changes from v1:
* only get the shutdown_future once and reuse it in the loop
 src/bin/proxmox-backup-proxy.rs | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 744a93f9..6a305b7c 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -394,14 +394,18 @@ async fn accept_connection(
     sender: tokio::sync::mpsc::Sender<ClientStreamResult>,
 ) {
     let accept_counter = Arc::new(());
+    let mut shutdown_future = proxmox_rest_server::shutdown_future().fuse();
 
     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;
+                }
+            },
+            _ =  shutdown_future => break,
         };
 
         sock.set_nodelay(true).unwrap();
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH v2] proxmox-backup-proxy: stop accept() loop on daemon shutdown
  2022-04-29 10:04 [pbs-devel] [PATCH v2] proxmox-backup-proxy: stop accept() loop on daemon shutdown Dominik Csapak
@ 2022-05-02 12:21 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-05-02 12:21 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

Am 4/29/22 um 12:04 schrieb Dominik Csapak:
> 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>
> ---
> changes from v1:
> * only get the shutdown_future once and reuse it in the loop
>  src/bin/proxmox-backup-proxy.rs | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
>

applied, thanks!

Added some more (root cause) info to the commit message and noted that
this alone doesn't explains the "why did it pop up *now*" question.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-02 12:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 10:04 [pbs-devel] [PATCH v2] proxmox-backup-proxy: stop accept() loop on daemon shutdown Dominik Csapak
2022-05-02 12:21 ` [pbs-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal