This allows nwfilterStateCleanupLocked to be used in
nwfilterStateInitialize in a later patch.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/nwfilter/nwfilter_driver.c | 89 +++++++++++++++++-----------------
1 file changed, 45 insertions(+), 44 deletions(-)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 26edfd3691..8eea9e5805 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -53,8 +53,6 @@ VIR_LOG_INIT("nwfilter.nwfilter_driver");
static virNWFilterDriverState *driver;
-static int nwfilterStateCleanup(void);
-
static int nwfilterStateReload(void);
static virMutex mutex = VIR_MUTEX_INITIALIZER;
@@ -150,6 +148,51 @@ virNWFilterTriggerRebuildImpl(void *opaque)
}
+static int
+nwfilterStateCleanupLocked(void)
+{
+ if (!driver)
+ return -1;
+
+ if (driver->privileged) {
+ virNWFilterConfLayerShutdown();
+ virNWFilterDHCPSnoopShutdown();
+ virNWFilterLearnShutdown();
+ virNWFilterIPAddrMapShutdown();
+ virNWFilterTechDriversShutdown();
+ nwfilterDriverRemoveDBusMatches();
+
+ if (driver->lockFD != -1)
+ virPidFileRelease(driver->stateDir, "driver",
driver->lockFD);
+
+ g_free(driver->stateDir);
+ g_free(driver->configDir);
+ g_free(driver->bindingDir);
+ }
+
+ virObjectUnref(driver->bindings);
+
+ /* free inactive nwfilters */
+ virNWFilterObjListFree(driver->nwfilters);
+
+ g_clear_pointer(&driver, g_free);
+
+ return 0;
+}
+
+/**
+ * nwfilterStateCleanup:
+ *
+ * Shutdown the nwfilter driver, it will stop all active nwfilters
+ */
+static int
+nwfilterStateCleanup(void)
+{
+ VIR_LOCK_GUARD lock = virLockGuardLock(&mutex);
+ return nwfilterStateCleanupLocked();
+}
+
+
/**
* nwfilterStateInitialize:
*
@@ -307,48 +350,6 @@ nwfilterStateReload(void)
}
-/**
- * nwfilterStateCleanup:
- *
- * Shutdown the nwfilter driver, it will stop all active nwfilters
- */
-static int
-nwfilterStateCleanup(void)
-{
- if (!driver)
- return -1;
-
- if (driver->privileged) {
- virNWFilterConfLayerShutdown();
- virNWFilterDHCPSnoopShutdown();
- virNWFilterLearnShutdown();
- virNWFilterIPAddrMapShutdown();
- virNWFilterTechDriversShutdown();
-
- nwfilterDriverLock();
-
- nwfilterDriverRemoveDBusMatches();
-
- if (driver->lockFD != -1)
- virPidFileRelease(driver->stateDir, "driver",
driver->lockFD);
-
- g_free(driver->stateDir);
- g_free(driver->configDir);
- g_free(driver->bindingDir);
- nwfilterDriverUnlock();
- }
-
- virObjectUnref(driver->bindings);
-
- /* free inactive nwfilters */
- virNWFilterObjListFree(driver->nwfilters);
-
- g_clear_pointer(&driver, g_free);
-
- return 0;
-}
-
-
static virDrvOpenStatus
nwfilterConnectOpen(virConnectPtr conn,
virConnectAuthPtr auth G_GNUC_UNUSED,
--
2.31.1