Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/test/test_driver.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4eca5c4a65..34e4652375 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1386,16 +1386,14 @@ testOpenFromFile(virConnectPtr conn, const char *file)
static int
testOpenDefault(virConnectPtr conn)
{
- int ret = VIR_DRV_OPEN_ERROR;
testDriver *privconn = NULL;
g_autoptr(xmlDoc) doc = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
size_t i;
+ VIR_LOCK_GUARD lock = virLockGuardLock(&defaultLock);
- virMutexLock(&defaultLock);
if (defaultPrivconn) {
conn->privateData = virObjectRef(defaultPrivconn);
- virMutexUnlock(&defaultLock);
return VIR_DRV_OPEN_SUCCESS;
}
@@ -1434,15 +1432,12 @@ testOpenDefault(virConnectPtr conn)
goto error;
defaultPrivconn = privconn;
- ret = VIR_DRV_OPEN_SUCCESS;
- cleanup:
- virMutexUnlock(&defaultLock);
- return ret;
+ return VIR_DRV_OPEN_SUCCESS;
error:
virObjectUnref(privconn);
conn->privateData = NULL;
- goto cleanup;
+ return VIR_DRV_OPEN_ERROR;
}
static int
@@ -1500,12 +1495,12 @@ testConnectAuthenticate(virConnectPtr conn,
static void
testDriverCloseInternal(testDriver *driver)
{
- virMutexLock(&defaultLock);
+ VIR_LOCK_GUARD lock = virLockGuardLock(&defaultLock);
+
testDriverDisposed = false;
virObjectUnref(driver);
if (testDriverDisposed && driver == defaultPrivconn)
defaultPrivconn = NULL;
- virMutexUnlock(&defaultLock);
}
--
2.31.1