]> git.proxmox.com Git - proxmox-backup.git/commitdiff
rest: daemon: sd notify barrier: allow caller to set timeout
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 1 Oct 2021 13:27:46 +0000 (15:27 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 2 Oct 2021 09:44:20 +0000 (11:44 +0200)
else it's rather to subtle and not a nice interface considering that
we only want to have a thin wrapper for sd_notify_barrier..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-rest-server/src/daemon.rs

index cf4a55324f69f043b63ba328cf2c13e5f6f881aa..63c57e2f52ec68067c0698fc88b62b005a41f42f 100644 (file)
@@ -188,7 +188,7 @@ impl Reloader {
                 }
                 // ensure systemd got the message about the new main PID before continuing, else it
                 // will get confused if the new main process sends its READY signal before that
-                if let Err(e) = systemd_notify_barrier() {
+                if let Err(e) = systemd_notify_barrier(u64::MAX) {
                     log::error!("failed to wait on systemd-processing: {}", e);
                 }
 
@@ -293,7 +293,7 @@ where
         if let Err(e) = systemd_notify(SystemdNotify::Reloading) {
             log::error!("failed to notify systemd about the state change: {}", e);
         }
-        if let Err(e) = systemd_notify_barrier() {
+        if let Err(e) = systemd_notify_barrier(u64::MAX) {
             log::error!("failed to wait on systemd-processing: {}", e);
         }
 
@@ -329,8 +329,8 @@ pub enum SystemdNotify {
 }
 
 /// Waits until all previously sent messages with sd_notify are processed
-pub fn systemd_notify_barrier() -> Result<(), Error> {
-    let rc = unsafe { sd_notify_barrier(0, u64::MAX) }; // infinite timeout
+pub fn systemd_notify_barrier(timeout: u64) -> Result<(), Error> {
+    let rc = unsafe { sd_notify_barrier(0, timeout) };
     if rc < 0 {
         bail!(
             "systemd_notify_barrier failed: {}",