Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
my $cfs_lock = sub {
my ($lockid, $timeout, $code, @param) = @_;
my $cfs_lock = sub {
my ($lockid, $timeout, $code, @param) = @_;
+ my $prev_alarm = alarm(0); # suspend outer alarm early
+
my $res;
my $got_lock = 0;
my $res;
my $got_lock = 0;
# fixed command timeout: cfs locks have a timeout of 120
# using 60 gives us another 60 seconds to abort the task
# fixed command timeout: cfs locks have a timeout of 120
# using 60 gives us another 60 seconds to abort the task
local $SIG{ALRM} = sub { die "got lock timeout - aborting command\n"; };
local $SIG{ALRM} = sub { die "got lock timeout - aborting command\n"; };
cfs_update(); # make sure we read latest versions inside code()
cfs_update(); # make sure we read latest versions inside code()
$err = "no quorum!\n" if !$got_lock && !check_cfs_quorum(1);
rmdir $filename if $got_lock; # if we held the lock always unlock again
$err = "no quorum!\n" if !$got_lock && !check_cfs_quorum(1);
rmdir $filename if $got_lock; # if we held the lock always unlock again
if ($err) {
$@ = "error with cfs lock '$lockid': $err";
return undef;
if ($err) {
$@ = "error with cfs lock '$lockid': $err";
return undef;