mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
uwrap: Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL macros
Introduce UWRAP_LOCK_ALL and UWRAP_UNLOCK_ALL which make locking easier. Signed-off-by: Robin Hack <hack.robin@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
308230d4fc
commit
526c1d5147
@ -51,6 +51,15 @@
|
||||
pthread_mutex_unlock(&( m ## _mutex)); \
|
||||
} while(0)
|
||||
|
||||
/* Add new global locks here please */
|
||||
# define UWRAP_LOCK_ALL \
|
||||
UWRAP_LOCK(uwrap_id); \
|
||||
UWRAP_LOCK(libc_symbol_binding); \
|
||||
|
||||
# define UWRAP_UNLOCK_ALL \
|
||||
UWRAP_UNLOCK(libc_symbol_binding); \
|
||||
UWRAP_UNLOCK(uwrap_id)
|
||||
|
||||
#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
|
||||
#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
|
||||
#else
|
||||
@ -654,8 +663,8 @@ static int uwrap_new_id(pthread_t tid, bool do_alloc)
|
||||
|
||||
static void uwrap_thread_prepare(void)
|
||||
{
|
||||
UWRAP_LOCK(uwrap_id);
|
||||
UWRAP_LOCK(libc_symbol_binding);
|
||||
UWRAP_LOCK_ALL;
|
||||
|
||||
/*
|
||||
* What happens if another atfork prepare functions calls a uwrap
|
||||
* function? So disable it in case another atfork prepare function
|
||||
@ -668,8 +677,7 @@ static void uwrap_thread_parent(void)
|
||||
{
|
||||
uwrap.enabled = true;
|
||||
|
||||
UWRAP_UNLOCK(libc_symbol_binding);
|
||||
UWRAP_UNLOCK(uwrap_id);
|
||||
UWRAP_UNLOCK_ALL;
|
||||
}
|
||||
|
||||
static void uwrap_thread_child(void)
|
||||
@ -1624,8 +1632,7 @@ void uwrap_destructor(void)
|
||||
{
|
||||
struct uwrap_thread *u = uwrap.ids;
|
||||
|
||||
UWRAP_LOCK(uwrap_id);
|
||||
UWRAP_LOCK(libc_symbol_binding);
|
||||
UWRAP_LOCK_ALL;
|
||||
|
||||
while (u != NULL) {
|
||||
UWRAP_DLIST_REMOVE(uwrap.ids, u);
|
||||
@ -1642,6 +1649,5 @@ void uwrap_destructor(void)
|
||||
dlclose(uwrap.libc.handle);
|
||||
}
|
||||
|
||||
UWRAP_UNLOCK(libc_symbol_binding);
|
||||
UWRAP_UNLOCK(uwrap_id);
|
||||
UWRAP_UNLOCK_ALL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user