]> git.proxmox.com Git - pve-cluster.git/commitdiff
add function to lock a domain
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 25 Sep 2015 15:50:05 +0000 (17:50 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 26 Sep 2015 08:29:27 +0000 (10:29 +0200)
This can be used to execute code on an 'action domain' basis.
E.g.: if there are actions that cannot be run simultaneously even if
they, for example, don't access a common file and maybe also spread
across different packages we can now secure the consistence of said
actions on an 'action domain' basis.

The need to use a dirty hack like cfs_lock_storage with some
arbitrary storage name becomes obsolete. Also the code behaviour
and meaning becomes clearer.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index a1b438caa620446bf758d215b963a5bc1e621312..55ccdb4de090ec63b5e6cbf5ca5893fa5ce402db 100644 (file)
@@ -927,6 +927,14 @@ sub cfs_lock_storage {
     &$cfs_lock($lockid, $timeout, $code, @param);
 }
 
+sub cfs_lock_domain {
+    my ($domainname, $timeout, $code, @param) = @_;
+
+    my $lockid = "domain-$domainname";
+
+    &$cfs_lock($lockid, $timeout, $code, @param);
+}
+
 my $log_levels = {
     "emerg" => 0,
     "alert" => 1,