tools/process_locker: Decrement writer count in drop handler

of ProcessLockSharedGuard.

We use a counter to determine if we can unlock the file again, but
we never actually decremented the writer count, so we held the
lock forever.

This fixes the issue that we could not start a garbage collect after
a reload, as long as the old process is still running, even when that
process has no active backup anymore but another long running task
(e.g. file download, terminal, etc.).

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-12-17 15:33:31 +01:00 committed by Dietmar Maurer
parent a7a5406c32
commit 3e2984bcb9
1 changed files with 3 additions and 1 deletions

View File

@ -55,7 +55,9 @@ impl Drop for ProcessLockSharedGuard {
if let Err(err) = nix::fcntl::fcntl(data.file.as_raw_fd(), nix::fcntl::FcntlArg::F_SETLKW(&op)) {
panic!("unable to drop writer lock - {}", err);
}
data.writers = 0;
}
if data.writers > 0 {
data.writers -= 1;
}
}
}