only wait 1 second to aquire lock on vm_create

Waiting is not necessary, and we want to avoid delays in the GUI.
This commit is contained in:
Dietmar Maurer 2012-03-27 08:50:04 +02:00
parent 18744ba33f
commit 191435c643
2 changed files with 11 additions and 5 deletions

View File

@ -342,7 +342,7 @@ __PACKAGE__->register_method({
my $createfn = sub {
# second test (after locking test is accurate)
# test after locking
die "unable to create vm $vmid: config file already exists\n"
if -f $filename;
@ -389,7 +389,7 @@ __PACKAGE__->register_method({
return $rpcenv->fork_worker('qmcreate', $vmid, $authuser, $realcmd);
};
return PVE::QemuServer::lock_config($vmid, $archive ? $restorefn : $createfn);
return PVE::QemuServer::lock_config_full($vmid, 1, $archive ? $restorefn : $createfn);
}});
__PACKAGE__->register_method({

View File

@ -1332,18 +1332,24 @@ sub check_type {
}
}
sub lock_config {
my ($vmid, $code, @param) = @_;
sub lock_config_full {
my ($vmid, $timeout, $code, @param) = @_;
my $filename = config_file_lock($vmid);
my $res = lock_file($filename, 10, $code, @param);
my $res = lock_file($filename, $timeout, $code, @param);
die $@ if $@;
return $res;
}
sub lock_config {
my ($vmid, $code, @param) = @_;
return lock_config_full($vmid, 10, $code, @param);
}
sub cfs_config_path {
my ($vmid, $node) = @_;