Re: [PATCH v1 11/20] node_device_udev: Move responsibility to release `(init|udev)Thread` to `udevEventDataDispose`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/19/24 9:49 AM, Marc Hartmayer wrote:
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.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
  src/node_device/node_device_udev.c | 14 ++++++--------
  1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 1c8832ebd990..7f233652b461 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -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;
@@ -1740,14 +1744,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);
@@ -2338,7 +2338,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;
      }
@@ -2370,7 +2369,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;
      }

Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux