On 9/3/24 10:36 AM, Martin Kletzander wrote:
The new function (networkCleanupInactive) can be called from an iterator
over the list of networks without the risk of deadlock.
Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
Reviewed-by: Laine Stump <laine@xxxxxxxxxx>
---
src/network/bridge_driver.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3ef3444da241..0e8057e24aed 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -325,10 +325,10 @@ networkDnsmasqConfigFileName(virNetworkDriverConfig *cfg,
}
-/* do needed cleanup steps and remove the network from the list */
+/* do needed cleanup steps */
static int
-networkRemoveInactive(virNetworkDriverState *driver,
- virNetworkObj *obj)
+networkCleanupInactive(virNetworkDriverState *driver,
+ virNetworkObj *obj)
{
g_autoptr(virNetworkDriverConfig) cfg = virNetworkDriverGetConfig(driver);
g_autofree char *leasefile = NULL;
@@ -372,6 +372,18 @@ networkRemoveInactive(virNetworkDriverState *driver,
/* remove status file */
unlink(statusfile);
+ return 0;
+}
+
+
+/* do needed cleanup steps and remove the network from the list */
+static int
+networkRemoveInactive(virNetworkDriverState *driver,
+ virNetworkObj *obj)
+{
+ if (networkCleanupInactive(driver, obj) < 0)
+ return -1;
+
/* remove the network definition */
virNetworkObjRemoveInactive(driver->networks, obj);