[libvirt PATCH 01/12] nwfilter_driver: Statically initialize mutex

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

 



This enables a later patch to simplify locking during initialization
and cleanup of virNWFilterDriverState.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/virnwfilterobj.h      |  1 -
 src/nwfilter/nwfilter_driver.c | 11 +++++------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index 44ba31f732..c365d0f28a 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -30,7 +30,6 @@ typedef struct _virNWFilterObjList virNWFilterObjList;
 
 typedef struct _virNWFilterDriverState virNWFilterDriverState;
 struct _virNWFilterDriverState {
-    virMutex lock;
     bool privileged;
 
     /* pid file FD, ensures two copies of the driver can't use the same root */
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 3ce8fce7f9..26edfd3691 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -57,13 +57,15 @@ static int nwfilterStateCleanup(void);
 
 static int nwfilterStateReload(void);
 
+static virMutex mutex = VIR_MUTEX_INITIALIZER;
+
 static void nwfilterDriverLock(void)
 {
-    virMutexLock(&driver->lock);
+    virMutexLock(&mutex);
 }
 static void nwfilterDriverUnlock(void)
 {
-    virMutexUnlock(&driver->lock);
+    virMutexUnlock(&mutex);
 }
 
 #ifdef WITH_FIREWALLD
@@ -174,10 +176,8 @@ nwfilterStateInitialize(bool privileged,
     driver = g_new0(virNWFilterDriverState, 1);
 
     driver->lockFD = -1;
-    if (virMutexInit(&driver->lock) < 0)
-        goto err_free_driverstate;
-
     driver->privileged = privileged;
+
     if (!(driver->nwfilters = virNWFilterObjListNew()))
         goto error;
 
@@ -343,7 +343,6 @@ nwfilterStateCleanup(void)
     /* free inactive nwfilters */
     virNWFilterObjListFree(driver->nwfilters);
 
-    virMutexDestroy(&driver->lock);
     g_clear_pointer(&driver, g_free);
 
     return 0;
-- 
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