]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpc: use VIR_LOCK_GUARD in remote client code
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 22 Dec 2022 15:28:50 +0000 (10:28 -0500)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 17 Jan 2023 17:33:54 +0000 (12:33 -0500)
Using VIR_LOCK_GUARD helps to simplify the control flow
logic.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/rpc/gendispatch.pl

index 54d55d91e7751f8cfdcc6ad4f6f1586094f40e06..63d2411474a1fb822f47c28affe48bfd82bb7249 100755 (executable)
@@ -1818,11 +1818,10 @@ elsif ($mode eq "client") {
             }
         }
 
-        print "\n";
         if ($structprefix eq "admin") {
-            print "    virObjectLock(priv);\n";
+            print "    VIR_LOCK_GUARD lock = virObjectLockGuard(&priv);\n";
         } else {
-            print "    remoteDriverLock(priv);\n";
+            print "    VIR_LOCK_GUARD lock = remoteDriverLock(priv);\n";
         }
 
         if ($call->{streamflag} ne "none") {
@@ -2020,12 +2019,6 @@ elsif ($mode eq "client") {
 
         print join("\n", @free_list);
 
-        if ($structprefix eq "admin") {
-            print "    virObjectUnlock(priv);\n";
-        } else {
-            print "    remoteDriverUnlock(priv);\n";
-        }
-
         print "    return rv;\n";
         print "}\n";
     }