summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2003-11-04 19:49:56 +0000
committerdeischen <deischen@FreeBSD.org>2003-11-04 19:49:56 +0000
commit96918b9811a81aec1bc2aaee34a0db88044994ee (patch)
treea33d6c63283c302eaad019257473e23862fdb6d0 /lib/libc/stdlib
parent07928289515debef8667077b7faedd939af2a8f0 (diff)
downloadFreeBSD-src-96918b9811a81aec1bc2aaee34a0db88044994ee.zip
FreeBSD-src-96918b9811a81aec1bc2aaee34a0db88044994ee.tar.gz
Externalize malloc's spinlock so that a thread library can take
it around an application's fork() call. Our new thread libraries (libthr, libpthread) can now have threads running while another thread calls fork(). In this case, it is possible for malloc to be left in an inconsistent state in the child. Our thread libraries, libpthread in particular, need to use malloc internally after a fork (in the child). Reviewed by: davidxu
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/malloc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 7006df2..d99457a 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
# include "libc_private.h"
# include "spinlock.h"
static spinlock_t thread_lock = _SPINLOCK_INITIALIZER;
+ spinlock_t *__malloc_lock = &thread_lock;
# define _MALLOC_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock);
# define _MALLOC_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock);
#endif /* __FreeBSD__ */
OpenPOWER on IntegriCloud