mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-27 22:10:40 +01:00
shared: fix behavior of NM_G_MUTEX_LOCKED()
The idea of NM_G_MUTEX_LOCKED() macro is not only to register a mutex for unlocking (via nm_auto_unlock_g_mutex) but also to lock it at the same time. That is a useful helper macro. If you have to lock the mutex yourself, it makes usage less convenient. At which point you don't need the macro anymore and you should instead take full control and lock/unlock yourself. Fix the macro and change behavior. The macro was not used so far, so it's not a problem. Fixes:dd33b3a14e('shared: add nm_auto_unlock_g_mutex and NM_G_MUTEX_LOCKED() helper macros') (cherry picked from commit098ac7dbc0) (cherry picked from commit3c27a3ed5f)
This commit is contained in:
parent
d26f17f24c
commit
4dfeec4eca
1 changed files with 7 additions and 2 deletions
|
|
@ -1787,8 +1787,13 @@ NM_AUTO_DEFINE_FCN_VOID0(GMutex *, _nm_auto_unlock_g_mutex, g_mutex_unlock);
|
|||
|
||||
#define nm_auto_unlock_g_mutex nm_auto(_nm_auto_unlock_g_mutex)
|
||||
|
||||
#define _NM_G_MUTEX_LOCKED(lock, uniq) \
|
||||
nm_auto_unlock_g_mutex GMutex *NM_UNIQ_T(nm_lock, uniq) = (lock)
|
||||
#define _NM_G_MUTEX_LOCKED(lock, uniq) \
|
||||
_nm_unused nm_auto_unlock_g_mutex GMutex *NM_UNIQ_T(nm_lock, uniq) = ({ \
|
||||
GMutex *const _lock = (lock); \
|
||||
\
|
||||
g_mutex_lock(_lock); \
|
||||
_lock; \
|
||||
})
|
||||
|
||||
#define NM_G_MUTEX_LOCKED(lock) _NM_G_MUTEX_LOCKED(lock, NM_UNIQ)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue