]> git.proxmox.com Git - pve-cluster.git/commitdiff
cfs_lock: save and restore outer alarm
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 9 Nov 2017 08:47:27 +0000 (09:47 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 9 Nov 2017 09:30:29 +0000 (10:30 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index af30f0911589669d6f040c4f4ef0d44ebd190f02..0a9dfa36b643c99181072ee88c28cfc3860e8a8b 100644 (file)
@@ -860,6 +860,8 @@ sub cfs_write_file {
 my $cfs_lock = sub {
     my ($lockid, $timeout, $code, @param) = @_;
 
+    my $prev_alarm = alarm(0); # suspend outer alarm early
+
     my $res;
     my $got_lock = 0;
 
@@ -895,8 +897,8 @@ my $cfs_lock = sub {
 
        # fixed command timeout: cfs locks have a timeout of 120
        # using 60 gives us another 60 seconds to abort the task
-       alarm(60);
        local $SIG{ALRM} = sub { die "got lock timeout - aborting command\n"; };
+       alarm(60);
 
        cfs_update(); # make sure we read latest versions inside code()
 
@@ -907,12 +909,12 @@ my $cfs_lock = sub {
 
     my $err = $@;
 
-    alarm(0);
-
     $err = "no quorum!\n" if !$got_lock && !check_cfs_quorum(1);
 
     rmdir $filename if $got_lock; # if we held the lock always unlock again
 
+    alarm($prev_alarm);
+
     if ($err) {
         $@ = "error with cfs lock '$lockid': $err";
         return undef;