diff options
author | Jason Evans <jasone@canonware.com> | 2012-05-12 00:40:16 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2012-05-12 00:40:16 (GMT) |
commit | 58ad1e4956affe0f9949445dce4410ad70b4cdac (patch) | |
tree | 05e57524cef05ab567bbb3fb6f693c454a7e1490 /src/jemalloc.c | |
parent | d8ceef6c5558fdab8f9448376ae065a9e5ffcbdd (diff) | |
download | jemalloc-58ad1e4956affe0f9949445dce4410ad70b4cdac.zip jemalloc-58ad1e4956affe0f9949445dce4410ad70b4cdac.tar.gz jemalloc-58ad1e4956affe0f9949445dce4410ad70b4cdac.tar.bz2 |
Return early in _malloc_{pre,post}fork() if uninitialized.
Avoid mutex operations in _malloc_{pre,post}fork() unless jemalloc has
been initialized.
Reported by David Xu.
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r-- | src/jemalloc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index d42e91d..bc54cd7 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1621,6 +1621,12 @@ _malloc_prefork(void) { unsigned i; +#ifdef JEMALLOC_MUTEX_INIT_CB + if (malloc_initialized == false) + return; +#endif + assert(malloc_initialized); + /* Acquire all mutexes in a safe order. */ malloc_mutex_prefork(&arenas_lock); for (i = 0; i < narenas; i++) { @@ -1642,6 +1648,12 @@ _malloc_postfork(void) { unsigned i; +#ifdef JEMALLOC_MUTEX_INIT_CB + if (malloc_initialized == false) + return; +#endif + assert(malloc_initialized); + /* Release all mutexes, now that fork() has completed. */ chunk_dss_postfork_parent(); huge_postfork_parent(); @@ -1658,6 +1670,8 @@ jemalloc_postfork_child(void) { unsigned i; + assert(malloc_initialized); + /* Release all mutexes, now that fork() has completed. */ chunk_dss_postfork_child(); huge_postfork_child(); |