mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
virNWFilterLockIface: Preserve correct lock ordering
In the not so distant past, the lock ordering in virNWFilterLockIface() was as follows: global mutex ifaceMapLock was acquired, then internal representation of given interface was looked up in a hash table (or created brand new if none was found), the global lock was released and the lock of the interface was acquired. But this was mistakenly changed as the function was rewritten to use automatic mutexes, because now the global lock is held throughout the whole run of the function and thus the interface specific lock is acquired with the global lock held. This results in a deadlock. Fixes: dd8150c48dcf94e8d3b0481be08eeef822b98b02 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Tested-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
db7b0b12b7
commit
af6f6091e0
@ -143,8 +143,10 @@ static bool threadsTerminate;
|
||||
int
|
||||
virNWFilterLockIface(const char *ifname)
|
||||
{
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&ifaceMapLock);
|
||||
virNWFilterIfaceLock *ifaceLock = virHashLookup(ifaceLockMap, ifname);
|
||||
virNWFilterIfaceLock *ifaceLock = NULL;
|
||||
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&ifaceMapLock) {
|
||||
ifaceLock = virHashLookup(ifaceLockMap, ifname);
|
||||
|
||||
if (!ifaceLock) {
|
||||
ifaceLock = g_new0(virNWFilterIfaceLock, 1);
|
||||
@ -173,6 +175,7 @@ virNWFilterLockIface(const char *ifname)
|
||||
}
|
||||
|
||||
ifaceLock->refctr++;
|
||||
}
|
||||
|
||||
virMutexLock(&ifaceLock->lock);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user