summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Hack <hack.robin@gmail.com>2015-01-23 15:29:35 +0100
committerAndreas Schneider <asn@cryptomilk.org>2015-01-28 17:17:08 +0100
commit526c1d514740956c9a9f6d83f99ceeca476130a8 (patch)
tree20607b6d4cb23587538331477b35c3f350231e50 /lib
parent308230d4fcb90822b81578624504d74ad2fbeab9 (diff)
downloadsamba-526c1d514740956c9a9f6d83f99ceeca476130a8.tar.gz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/uid_wrapper/uid_wrapper.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/uid_wrapper/uid_wrapper.c b/lib/uid_wrapper/uid_wrapper.c
index 50dfaa4b165..b04e334cac5 100644
--- a/lib/uid_wrapper/uid_wrapper.c
+++ b/lib/uid_wrapper/uid_wrapper.c
@@ -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;
}