rest: daemon: sd notify barrier: avoid barging in between SystemdNotify enum and systemd_notify

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-10-01 16:44:28 +02:00
parent 058b4b9708
commit 31142ef291

View File

@ -328,19 +328,6 @@ pub enum SystemdNotify {
MainPid(nix::unistd::Pid),
}
/// Waits until all previously sent messages with sd_notify are processed
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: {}",
std::io::Error::from_raw_os_error(-rc),
);
}
Ok(())
}
/// Tells systemd the startup state of the service (see: ``man sd_notify``)
pub fn systemd_notify(state: SystemdNotify) -> Result<(), Error> {
@ -365,3 +352,12 @@ pub fn systemd_notify(state: SystemdNotify) -> Result<(), Error> {
Ok(())
}
/// Waits until all previously sent messages with sd_notify are processed
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: {}", std::io::Error::from_raw_os_error(-rc));
}
Ok(())
}