Skip to content
Snippets Groups Projects
Commit e83301f4 authored by Morris Jette's avatar Morris Jette
Browse files

Change glibc time function wrappers locks

The previous logic could deadlock with the log functions pthead_atfork()
functions depending upon the call order.
parent 9c4eb043
No related branches found
No related tags found
No related merge requests found
......@@ -48,15 +48,13 @@
# include <pthread.h>
static pthread_mutex_t time_lock = PTHREAD_MUTEX_INITIALIZER;
static void _atfork_prep() { slurm_mutex_lock(&time_lock); }
static void _atfork_parent() { slurm_mutex_unlock(&time_lock); }
static void _atfork_child() { slurm_mutex_unlock(&time_lock); }
static void _atfork_child() { pthread_mutex_init(&time_lock, NULL); }
static bool at_forked = false;
inline static void _init(void)
{
while (!at_forked) {
pthread_atfork(_atfork_prep, _atfork_parent, _atfork_child);
pthread_atfork(NULL, NULL, _atfork_child);
at_forked = true;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment