]> git.proxmox.com Git - pve-cluster.git/commitdiff
cfs_lock: subtract sleep time from rest timeout
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 9 Nov 2017 09:36:51 +0000 (10:36 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 9 Nov 2017 09:36:53 +0000 (10:36 +0100)
We take the left-over timeout returned from alarm() and then
sleep for a second, so when continuing the alarm timeout we
we need to subtract that second for consistency.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
data/PVE/Cluster.pm

index 0a9dfa36b643c99181072ee88c28cfc3860e8a8b..21c1f1363e3bcbbbe696d253aa81ab3a88f18479 100644 (file)
@@ -884,11 +884,11 @@ my $cfs_lock = sub {
        while (1) {
            alarm ($timeout);
            $got_lock = mkdir($filename);
-           $timeout = alarm(0);
+           $timeout = alarm(0) - 1; # we'll sleep for 1s, see down below
 
            last if $got_lock;
 
-           $timeout_err->() if $timeout == 0;
+           $timeout_err->() if $timeout <= 0;
 
            print STDERR "trying to aquire cfs lock '$lockid' ...";
            utime (0, 0, $filename); # cfs unlock request