[pbs-devel] [PATCH proxmox-backup 4/5] backup: use flock on backup group to forbid multiple backups at once

Dietmar Maurer dietmar at proxmox.com
Thu Jul 30 07:50:53 CEST 2020


> +        // acquire in non-blocking mode, no point in waiting here since other
> +        // backups could still take a very long time
> +        tools::lock_file(&mut handle, true, Some(Duration::from_nanos(0)))
> +            .map_err(|err| {
> +                match err.downcast_ref::<nix::Error>() {
> +                    Some(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => {

Honestly, I would remove this special case with downcast - the default error message is good enough. Isn't it?

> +                        return format_err!(
> +                            "unable to acquire lock on backup group {:?} - another backup is already running",
> +                            self.group_path(),
> +                        );
> +                    },
> +                    _ => ()
> +                }
> +                format_err!(
> +                    "unable to acquire lock on backup group {:?} - {}",
> +                    self.group_path(),
> +                    err,
> +                )
> +            })?;
> +
> +        Ok(handle)
> +    }
> +





More information about the pbs-devel mailing list