From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH] api server: make incoming connection handling robust
Date: Fri, 8 Aug 2025 10:26:26 +0200 [thread overview]
Message-ID: <20250808082643.167441-1-f.gruenbichler@proxmox.com> (raw)
breaking from this loop when encountering an error means no longer accepting
new connections, and must be avoided at all costs.
this matches the changes in proxmox-backup-server for the same issue.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
server/src/bin/proxmox-datacenter-api/main.rs | 16 ++++++++++------
.../bin/proxmox-datacenter-privileged-api.rs | 18 ++++++++++++++----
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/server/src/bin/proxmox-datacenter-api/main.rs b/server/src/bin/proxmox-datacenter-api/main.rs
index e92232e..db6b258 100644
--- a/server/src/bin/proxmox-datacenter-api/main.rs
+++ b/server/src/bin/proxmox-datacenter-api/main.rs
@@ -278,13 +278,17 @@ async fn run(debug: bool) -> Result<(), Error> {
Some(conn) = secure_connections.next() => {
match conn {
Ok(conn) => {
- let api_service = rest_server.api_service(&conn)?;
- let watcher = graceful.watcher();
- tokio::spawn(async move {
- api_service.serve(conn, Some(watcher)).await
- });
+ match rest_server.api_service(&conn) {
+ Ok(api_service) => {
+ let watcher = graceful.watcher();
+ tokio::spawn(async move {
+ api_service.serve(conn, Some(watcher)).await
+ });
+ }
+ Err(err) => log::warn!("Failed to get api service: {err:?}"),
+ }
},
- Err(err) => { log::warn!("Failed to accept insecure connection: {err:?}"); }
+ Err(err) => { log::warn!("Failed to accept secure connection: {err:?}"); }
}
},
_shutdown = proxmox_daemon::shutdown_future() => {
diff --git a/server/src/bin/proxmox-datacenter-privileged-api.rs b/server/src/bin/proxmox-datacenter-privileged-api.rs
index b62f4ea..66033eb 100644
--- a/server/src/bin/proxmox-datacenter-privileged-api.rs
+++ b/server/src/bin/proxmox-datacenter-privileged-api.rs
@@ -181,10 +181,20 @@ async fn run() -> Result<(), Error> {
loop {
tokio::select! {
incoming = listener.accept() => {
- let (conn, _) = incoming?;
- let api_service = rest_server.api_service(&conn)?;
- let watcher = graceful.watcher();
- tokio::spawn(async move { api_service.serve(conn, Some(watcher)).await });
+ match incoming {
+ Ok((conn, _)) => {
+ match rest_server.api_service(&conn) {
+ Ok(api_service) => {
+ let watcher = graceful.watcher();
+ tokio::spawn(async move {
+ api_service.serve(conn, Some(watcher)).await
+ });
+ }
+ Err(err) => log::warn!("Failed to get api service: {err:?}"),
+ }
+ },
+ Err(err) => log::warn!("Failed to accept secure connection: {err:?}"),
+ };
},
_shutdown = proxmox_daemon::shutdown_future() => {
break;
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next reply other threads:[~2025-08-08 8:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 8:26 Fabian Grünbichler [this message]
2025-08-08 11:11 ` [pdm-devel] applied: " Thomas Lamprecht
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=20250808082643.167441-1-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pdm-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