[PATCH 1/2] virSecurityManagerMetadataLock: Expand the comment on deadlocks

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

 



Document why we need to sort paths while it's still fresh in my
memory.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/security/security_manager.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index c205c3bf17..ade2c96141 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -1289,7 +1289,12 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
     if (VIR_ALLOC_N(fds, npaths) < 0)
         return NULL;
 
-    /* Sort paths to lock in order to avoid deadlocks. */
+    /* Sort paths to lock in order to avoid deadlocks with other
+     * processes. For instance, if one process wants to lock
+     * paths A B and there's another that is trying to lock them
+     * in reversed order a deadlock might occur.  But if we sort
+     * the paths alphabetically then both processes will try lock
+     * paths in the same order and thus no deadlock can occur. */
     qsort(paths, npaths, sizeof(*paths), cmpstringp);
 
     for (i = 0; i < npaths; i++) {
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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