/* The mutex or accessing the id */
static pthread_mutex_t uwrap_id_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* The mutex for accessing the global libc.fns */
+static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
+
/*********************************************************
* UWRAP PROTOTYPES
*********************************************************/
}
#define uwrap_load_lib_function(lib, fn_name) \
+ UWRAP_LOCK(libc_symbol_binding); \
if (uwrap.libc.fns._libc_##fn_name == NULL) { \
*(void **) (&uwrap.libc.fns._libc_##fn_name) = \
_uwrap_load_lib_function(lib, #fn_name); \
- }
+ } \
+ UWRAP_UNLOCK(libc_symbol_binding)
/*
* IMPORTANT
static void uwrap_thread_prepare(void)
{
UWRAP_LOCK(uwrap_id);
-
+ UWRAP_LOCK(libc_symbol_binding);
/*
* What happens if another atfork prepare functions calls a uwrap
* function? So disable it in case another atfork prepare function
{
uwrap.enabled = true;
+ UWRAP_UNLOCK(libc_symbol_binding);
UWRAP_UNLOCK(uwrap_id);
}
{
uwrap.enabled = true;
+ UWRAP_UNLOCK(libc_symbol_binding);
UWRAP_UNLOCK(uwrap_id);
}
struct uwrap_thread *u = uwrap.ids;
UWRAP_LOCK(uwrap_id);
+ UWRAP_LOCK(libc_symbol_binding);
+
while (u != NULL) {
UWRAP_DLIST_REMOVE(uwrap.ids, u);
u = uwrap.ids;
}
- UWRAP_UNLOCK(uwrap_id);
if (uwrap.libc.handle != NULL) {
dlclose(uwrap.libc.handle);
}
+
+ UWRAP_UNLOCK(libc_symbol_binding);
+ UWRAP_UNLOCK(uwrap_id);
}