replication: use a dedicated lock file

Otherwise $update_job_state's file_set_contents() call
drops our lock.
This commit is contained in:
Wolfgang Bumiller 2017-06-01 15:26:01 +02:00 committed by Dietmar Maurer
parent c4ca87e508
commit dc213d136f
3 changed files with 5 additions and 3 deletions

View File

@ -22,6 +22,7 @@ use PVE::ReplicationConfig;
# Note: regression tests can overwrite $state_path for testing
our $state_path = "/var/lib/pve-manager/pve-replication-state.json";
our $pvesr_lock_path = "/var/lock/pvesr.lck";
my $update_job_state = sub {
my ($stateobj, $jobcfg, $state) = @_;
@ -506,7 +507,7 @@ sub run_single_job {
$run_replication->($stateobj, $jobcfg, $now, $logfunc);
};
my $res = PVE::Tools::lock_file($state_path, 60, $code);
my $res = PVE::Tools::lock_file($pvesr_lock_path, 60, $code);
die $@ if $@;
}
@ -525,7 +526,7 @@ sub run_jobs {
}
};
my $res = PVE::Tools::lock_file($state_path, 60, $code);
my $res = PVE::Tools::lock_file($pvesr_lock_path, 60, $code);
die $@ if $@;
}

View File

@ -18,4 +18,4 @@ install:
.PHONY: clean
clean:
rm -rf *~
rm -rf *~ .mocked_* *.tmp

View File

@ -60,6 +60,7 @@ my $statefile = ".mocked_repl_state";
unlink $statefile;
$PVE::Replication::state_path = $statefile;
$PVE::Replication::pvesr_lock_path = ".mocked_pvesr_lock";
my $mocked_write_state = sub {
my ($state) = @_;