summaryrefslogtreecommitdiffstats
path: root/lib/uid_wrapper/uid_wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uid_wrapper/uid_wrapper.c')
-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 50dfaa4b16..b04e334cac 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;
}