From 514a545f8a3983d53b7de4e8dfcefe16c9496776 Mon Sep 17 00:00:00 2001 From: guenther Date: Tue, 7 Apr 2015 01:27:06 +0000 Subject: Make pthread_atfork() track the DSO that called it like atexit() does, unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@ --- lib/librthread/rthread_libc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/librthread/rthread_libc.c') diff --git a/lib/librthread/rthread_libc.c b/lib/librthread/rthread_libc.c index 13df27c498e..018368a84dd 100644 --- a/lib/librthread/rthread_libc.c +++ b/lib/librthread/rthread_libc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_libc.c,v 1.11 2013/06/01 20:47:40 tedu Exp $ */ +/* $OpenBSD: rthread_libc.c,v 1.12 2015/04/07 01:27:07 guenther Exp $ */ /* $snafu: libc_tag.c,v 1.4 2004/11/30 07:00:06 marc Exp $ */ /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman */ @@ -183,6 +183,23 @@ _thread_atexit_unlock(void) _spinunlock(&atexit_lock); } +/* + * atfork lock + */ +static struct _spinlock atfork_lock = _SPINLOCK_UNLOCKED; + +void +_thread_atfork_lock(void) +{ + _spinlock(&atfork_lock); +} + +void +_thread_atfork_unlock(void) +{ + _spinunlock(&atfork_lock); +} + /* * arc4random lock */ -- cgit v1.2.3-59-g8ed1b