mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vbox: Use automatic mutex management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ae24a63ef8
commit
f9c863237f
@ -224,7 +224,7 @@ vboxSdkUninitialize(void)
|
|||||||
static struct _vboxDriver *
|
static struct _vboxDriver *
|
||||||
vboxGetDriverConnection(void)
|
vboxGetDriverConnection(void)
|
||||||
{
|
{
|
||||||
virMutexLock(&vbox_driver_lock);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&vbox_driver_lock);
|
||||||
|
|
||||||
if (vbox_driver) {
|
if (vbox_driver) {
|
||||||
virObjectRef(vbox_driver);
|
virObjectRef(vbox_driver);
|
||||||
@ -234,9 +234,6 @@ vboxGetDriverConnection(void)
|
|||||||
if (!vbox_driver) {
|
if (!vbox_driver) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to create vbox driver object."));
|
_("Failed to create vbox driver object."));
|
||||||
|
|
||||||
virMutexUnlock(&vbox_driver_lock);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,26 +245,20 @@ vboxGetDriverConnection(void)
|
|||||||
virObjectUnref(vbox_driver);
|
virObjectUnref(vbox_driver);
|
||||||
if (vboxDriverDisposed)
|
if (vboxDriverDisposed)
|
||||||
vbox_driver = NULL;
|
vbox_driver = NULL;
|
||||||
|
|
||||||
virMutexUnlock(&vbox_driver_lock);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vbox_driver->connectionCount++;
|
vbox_driver->connectionCount++;
|
||||||
|
|
||||||
virMutexUnlock(&vbox_driver_lock);
|
|
||||||
|
|
||||||
return vbox_driver;
|
return vbox_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vboxDestroyDriverConnection(void)
|
vboxDestroyDriverConnection(void)
|
||||||
{
|
{
|
||||||
virMutexLock(&vbox_driver_lock);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&vbox_driver_lock);
|
||||||
|
|
||||||
if (!vbox_driver)
|
if (!vbox_driver)
|
||||||
goto cleanup;
|
return;
|
||||||
|
|
||||||
vbox_driver->connectionCount--;
|
vbox_driver->connectionCount--;
|
||||||
|
|
||||||
@ -277,9 +268,6 @@ vboxDestroyDriverConnection(void)
|
|||||||
virObjectUnref(vbox_driver);
|
virObjectUnref(vbox_driver);
|
||||||
if (vboxDriverDisposed)
|
if (vboxDriverDisposed)
|
||||||
vbox_driver = NULL;
|
vbox_driver = NULL;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virMutexUnlock(&vbox_driver_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int openSessionForMachine(struct _vboxDriver *data, const unsigned char *dom_uuid,
|
static int openSessionForMachine(struct _vboxDriver *data, const unsigned char *dom_uuid,
|
||||||
|
Loading…
Reference in New Issue
Block a user