mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
virNWFilterDriverState: Destroy mutex safely
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
008162e12a
commit
8bbb8d6a58
@ -45,6 +45,7 @@ struct _virNWFilterDriverState {
|
||||
|
||||
/* Recursive. Hold for filter changes, instantiation or deletion */
|
||||
virMutex updateLock;
|
||||
bool updateLockInitialized;
|
||||
};
|
||||
|
||||
virNWFilterDef *
|
||||
|
@ -173,6 +173,7 @@ nwfilterStateCleanupLocked(void)
|
||||
/* free inactive nwfilters */
|
||||
virNWFilterObjListFree(driver->nwfilters);
|
||||
|
||||
if (driver->updateLockInitialized)
|
||||
virMutexDestroy(&driver->updateLock);
|
||||
g_clear_pointer(&driver, g_free);
|
||||
|
||||
@ -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()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user