[PATCH 18/43] lxc: lxc_fuse: convert virMutex to GMutex

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

 



Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx>
---
 src/lxc/lxc_fuse.c | 13 +++++--------
 src/lxc/lxc_fuse.h |  2 +-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index e73b4d0690..e35086c859 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -262,11 +262,10 @@ static struct fuse_operations lxcProcOper = {
 
 static void lxcFuseDestroy(virLXCFusePtr fuse)
 {
-    virMutexLock(&fuse->lock);
+    g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&fuse->lock);
     fuse_unmount(fuse->mountpoint, fuse->ch);
     fuse_destroy(fuse->fuse);
     fuse->fuse = NULL;
-    virMutexUnlock(&fuse->lock);
 }
 
 static void lxcFuseRun(void *opaque)
@@ -291,8 +290,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
 
     fuse->def = def;
 
-    if (virMutexInit(&fuse->lock) < 0)
-        goto cleanup2;
+    g_mutex_init(&fuse->lock);
 
     fuse->mountpoint = g_strdup_printf("%s/%s.fuse/", LXC_STATE_DIR, def->name);
 
@@ -327,8 +325,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
     return ret;
  cleanup1:
     VIR_FREE(fuse->mountpoint);
-    virMutexDestroy(&fuse->lock);
- cleanup2:
+    g_mutex_clear(&fuse->lock);
     VIR_FREE(fuse);
     goto cleanup;
 }
@@ -351,10 +348,10 @@ void lxcFreeFuse(virLXCFusePtr *f)
     if (fuse) {
         /* exit fuse_loop, lxcFuseRun thread may try to destroy
          * fuse->fuse at the same time,so add a lock here. */
-        virMutexLock(&fuse->lock);
+        g_mutex_lock(&fuse->lock);
         if (fuse->fuse)
             fuse_exit(fuse->fuse);
-        virMutexUnlock(&fuse->lock);
+        g_mutex_unlock(&fuse->lock);
 
         VIR_FREE(fuse->mountpoint);
         VIR_FREE(*f);
diff --git a/src/lxc/lxc_fuse.h b/src/lxc/lxc_fuse.h
index e9cfd9a20a..47ca7197fc 100644
--- a/src/lxc/lxc_fuse.h
+++ b/src/lxc/lxc_fuse.h
@@ -48,7 +48,7 @@ struct virLXCFuse {
     char *mountpoint;
     struct fuse *fuse;
     struct fuse_chan *ch;
-    virMutex lock;
+    GMutex lock;
 };
 typedef struct virLXCFuse *virLXCFusePtr;
 
-- 
2.25.2






[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