[libvirt PATCH 07/10] vbox: Use automatic mutex management

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/vbox/vbox_common.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 40180b0dfd..36db6e06be 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -224,7 +224,7 @@ vboxSdkUninitialize(void)
 static struct _vboxDriver *
 vboxGetDriverConnection(void)
 {
-    virMutexLock(&vbox_driver_lock);
+    VIR_LOCK_GUARD lock = virLockGuardLock(&vbox_driver_lock);
 
     if (vbox_driver) {
         virObjectRef(vbox_driver);
@@ -234,9 +234,6 @@ vboxGetDriverConnection(void)
         if (!vbox_driver) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Failed to create vbox driver object."));
-
-            virMutexUnlock(&vbox_driver_lock);
-
             return NULL;
         }
     }
@@ -248,26 +245,20 @@ vboxGetDriverConnection(void)
         virObjectUnref(vbox_driver);
         if (vboxDriverDisposed)
             vbox_driver = NULL;
-
-        virMutexUnlock(&vbox_driver_lock);
-
         return NULL;
     }
 
     vbox_driver->connectionCount++;
-
-    virMutexUnlock(&vbox_driver_lock);
-
     return vbox_driver;
 }
 
 static void
 vboxDestroyDriverConnection(void)
 {
-    virMutexLock(&vbox_driver_lock);
+    VIR_LOCK_GUARD lock = virLockGuardLock(&vbox_driver_lock);
 
     if (!vbox_driver)
-        goto cleanup;
+        return;
 
     vbox_driver->connectionCount--;
 
@@ -277,9 +268,6 @@ vboxDestroyDriverConnection(void)
     virObjectUnref(vbox_driver);
     if (vboxDriverDisposed)
         vbox_driver = NULL;
-
- cleanup:
-    virMutexUnlock(&vbox_driver_lock);
 }
 
 static int openSessionForMachine(struct _vboxDriver *data, const unsigned char *dom_uuid,
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux