[PATCH 26/43] remote: remote_driver: convert virMutex to GMutex

Rafael Fonseca r4f4rfs at gmail.com
Fri Apr 10 13:54:53 UTC 2020


Signed-off-by: Rafael Fonseca <r4f4rfs at gmail.com>
---
 src/remote/remote_driver.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 7bae0c2514..6cd38e86ef 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -116,7 +116,7 @@ VIR_ENUM_IMPL(remoteDriverMode,
 static bool inside_daemon;
 
 struct private_data {
-    virMutex lock;
+    GMutex lock;
 
     virNetClientPtr client;
     virNetClientProgramPtr remoteProgram;
@@ -147,12 +147,12 @@ enum {
 
 static void remoteDriverLock(struct private_data *driver)
 {
-    virMutexLock(&driver->lock);
+    g_mutex_lock(&driver->lock);
 }
 
 static void remoteDriverUnlock(struct private_data *driver)
 {
-    virMutexUnlock(&driver->lock);
+    g_mutex_unlock(&driver->lock);
 }
 
 static int call(virConnectPtr conn, struct private_data *priv,
@@ -1393,12 +1393,7 @@ remoteAllocPrivateData(void)
     if (VIR_ALLOC(priv) < 0)
         return NULL;
 
-    if (virMutexInit(&priv->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot initialize mutex"));
-        VIR_FREE(priv);
-        return NULL;
-    }
+    g_mutex_init(&priv->lock);
     remoteDriverLock(priv);
     priv->localUses = 1;
 
@@ -1561,7 +1556,7 @@ remoteConnectClose(virConnectPtr conn)
         ret = doRemoteClose(conn, priv);
         conn->privateData = NULL;
         remoteDriverUnlock(priv);
-        virMutexDestroy(&priv->lock);
+        g_mutex_clear(&priv->lock);
         VIR_FREE(priv);
     }
     if (priv)
-- 
2.25.2





More information about the libvir-list mailing list