mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 13:17:58 +03:00
virSecurityManagerMetadataLock: Expand the comment on deadlocks
Document why we need to sort paths while it's still fresh in my memory. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
48df09874b
commit
ee6501ab05
@ -1289,7 +1289,12 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||||||
if (VIR_ALLOC_N(fds, npaths) < 0)
|
if (VIR_ALLOC_N(fds, npaths) < 0)
|
||||||
return NULL;
|
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);
|
qsort(paths, npaths, sizeof(*paths), cmpstringp);
|
||||||
|
|
||||||
for (i = 0; i < npaths; i++) {
|
for (i = 0; i < npaths; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user