summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-27 20:17:48 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-27 20:17:48 +0100
commitba1101b8755f1e843af4d9b160533f0b11e4b598 (patch)
treeed724b111707592a69e6a5145300146688db69c8
parentf58ab00078c28339a6dd2d0ff12b7928522cdbe2 (diff)
Use libc lock instead of cthreads lock for atfork_lock
* forward.c: Include <libc-lock.h> (atfork_lock): Use libc_lock instead of struct mutex. (atfork_pthread_prepare, atfork_pthread_parent, atfork_pthread_child, __register_atfork, __unregister_atfork): Use __libc_lock_lock/unlock instead of __mutex_lock/unlock.
-rw-r--r--forward.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/forward.c b/forward.c
index 0ee84a0..ea25935 100644
--- a/forward.c
+++ b/forward.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <shlib-compat.h>
#include <pthread-functions.h>
+#include <libc-lock.h>
#include <fork.h>
/* Pointers to the libc functions. */
@@ -155,7 +156,7 @@ struct atfork {
};
/* TODO: better locking */
-static struct mutex atfork_lock;
+__libc_lock_define_initialized(static, atfork_lock);
static struct atfork *fork_handlers, *fork_last_handler;
static void
@@ -163,10 +164,10 @@ atfork_pthread_prepare (void)
{
struct atfork *handlers, *last_handler;
- __mutex_lock (&atfork_lock);
+ __libc_lock_lock (atfork_lock);
handlers = fork_handlers;
last_handler = fork_last_handler;
- __mutex_unlock (&atfork_lock);
+ __libc_lock_unlock (atfork_lock);
if (!last_handler)
return;
@@ -187,9 +188,9 @@ atfork_pthread_parent (void)
{
struct atfork *handlers;
- __mutex_lock (&atfork_lock);
+ __libc_lock_lock (atfork_lock);
handlers = fork_handlers;
- __mutex_unlock (&atfork_lock);
+ __libc_lock_unlock (atfork_lock);
while (handlers)
{
@@ -205,9 +206,9 @@ atfork_pthread_child (void)
{
struct atfork *handlers;
- __mutex_lock (&atfork_lock);
+ __libc_lock_lock (atfork_lock);
handlers = fork_handlers;
- __mutex_unlock (&atfork_lock);
+ __libc_lock_unlock (atfork_lock);
while (handlers)
{
@@ -235,14 +236,14 @@ __register_atfork (
new->dso_handle = dso_handle;
new->prev = NULL;
- __mutex_lock (&atfork_lock);
+ __libc_lock_lock (atfork_lock);
new->next = fork_handlers;
if (fork_handlers)
fork_handlers->prev = new;
fork_handlers = new;
if (!fork_last_handler)
fork_last_handler = new;
- __mutex_unlock (&atfork_lock);
+ __libc_lock_unlock (atfork_lock);
return 0;
}
@@ -252,7 +253,7 @@ void
__unregister_atfork (void *dso_handle)
{
struct atfork **handlers, *prev = NULL, *next;
- __mutex_lock (&atfork_lock);
+ __libc_lock_lock (atfork_lock);
handlers = &fork_handlers;
while (*handlers)
{
@@ -277,5 +278,5 @@ __unregister_atfork (void *dso_handle)
handlers = &prev->next;
}
}
- __mutex_unlock (&atfork_lock);
+ __libc_lock_unlock (atfork_lock);
}