]> xenbits.xensource.com Git - libvirt.git/commitdiff
node_device_udev: Move responsibility to release `(init|udev)Thread` to `udevEventDat...
authorMarc Hartmayer <mhartmay@linux.ibm.com>
Tue, 23 Apr 2024 18:08:57 +0000 (20:08 +0200)
committerJonathon Jongsma <jjongsma@redhat.com>
Tue, 18 Jun 2024 14:00:24 +0000 (09:00 -0500)
Everything is released in `udevEventDataDispose` except for the threads, change
this as this makes the code easier to read as it can be simplified a little.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
src/node_device/node_device_udev.c

index f3cf124bdd898a25f1c0dba8e974529a5d52a4e1..921710d16311d8f86f58f692a864d8d71c413536 100644 (file)
@@ -86,12 +86,16 @@ udevEventDataDispose(void *obj)
     struct udev *udev = NULL;
     udevEventData *priv = obj;
 
+    g_clear_pointer(&priv->initThread, g_free);
+
     if (priv->watch != -1)
         virEventRemoveHandle(priv->watch);
 
     if (priv->mdevctlTimeout != -1)
         virEventRemoveTimeout(priv->mdevctlTimeout);
 
+    g_clear_pointer(&priv->udevThread, g_free);
+
     if (!priv->udev_monitor)
         return;
 
@@ -1730,14 +1734,10 @@ nodeStateCleanup(void)
             priv->udevThreadQuit = true;
             virCondSignal(&priv->udevThreadCond);
         }
-        if (priv->initThread) {
+        if (priv->initThread)
             virThreadJoin(priv->initThread);
-            g_clear_pointer(&priv->initThread, g_free);
-        }
-        if (priv->udevThread) {
+        if (priv->udevThread)
             virThreadJoin(priv->udevThread);
-            g_clear_pointer(&priv->udevThread, g_free);
-        }
     }
 
     virObjectUnref(priv);
@@ -2328,7 +2328,6 @@ nodeStateInitialize(bool privileged,
                             "udev-event", false, NULL) < 0) {
         virReportSystemError(errno, "%s",
                              _("failed to create udev handler thread"));
-        g_clear_pointer(&priv->udevThread, g_free);
         goto unlock;
     }
 
@@ -2360,7 +2359,6 @@ nodeStateInitialize(bool privileged,
                             "nodedev-init", false, udev) < 0) {
         virReportSystemError(errno, "%s",
                              _("failed to create udev enumerate thread"));
-        g_clear_pointer(&priv->initThread, g_free);
         goto cleanup;
     }