Allow nwfilterStateCleanupLocked to be called on a partially constructed
driver object.
This enables the next patch to simplify and fix error handling in
nwfilterStateInitialize.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/virnwfilterobj.h | 1 +
src/nwfilter/nwfilter_driver.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index cb103280e8..b67dc017c5 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -45,6 +45,7 @@ struct _virNWFilterDriverState {
/* Recursive. Hold for filter changes, instantiation or deletion */
virMutex updateLock;
+ bool updateLockInitialized;
};
virNWFilterDef *
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index f89b5b8757..bf17c5ea66 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -173,7 +173,8 @@ nwfilterStateCleanupLocked(void)
/* free inactive nwfilters */
virNWFilterObjListFree(driver->nwfilters);
- virMutexDestroy(&driver->updateLock);
+ if (driver->updateLockInitialized)
+ virMutexDestroy(&driver->updateLock);
g_clear_pointer(&driver, g_free);
return 0;
@@ -222,6 +223,7 @@ nwfilterStateInitialize(bool privileged,
if (virMutexInitRecursive(&driver->updateLock) < 0)
goto err_free_driverstate;
+ driver->updateLockInitialized = true;
driver->privileged = privileged;
if (!(driver->nwfilters = virNWFilterObjListNew()))
--
2.31.1