[RFC PATCH v1 3/5] node_device_udev: Add comments about locking

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

 



Commit a99d876a0f58 ("node_device: Use automatic mutex management") replaced the
locking mechanism and accidentally removed the comment with the reason why the
lock is taken. Restore this comment and add a new comment about the lock.

Note: If the comment is/was correct, then  each caller of `nodeDeviceUpdateMediatedDevices` must hold this lock.
      Currently, that's not the case.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
 src/node_device/node_device_udev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9f2abb9eb0dd..8b4a62537c06 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -72,8 +72,10 @@ struct _udevEventData {
     /* init thread */
     virThread *initThread;
 
-    GList *mdevctlMonitors;
+    /* Protects @mdevctlMonitors and must be taken when `mdevctl` command is
+     * called to make sure only one thread can query mdevctl at a time. */
     virMutex mdevctlLock;
+    GList *mdevctlMonitors;
     int mdevctlTimeout;
 };
 
@@ -2065,6 +2067,7 @@ static void
 mdevctlUpdateThreadFunc(void *opaque G_GNUC_UNUSED)
 {
     udevEventData *priv = driver->privateData;
+    /* ensure only a single thread can query mdevctl at a time */
     VIR_LOCK_GUARD lock = virLockGuardLock(&priv->mdevctlLock);
 
     if (nodeDeviceUpdateMediatedDevices() < 0)
-- 
2.34.1
_______________________________________________
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