summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2011-11-04 01:40:03 (GMT)
committerJason Evans <je@fb.com>2011-11-06 04:48:06 (GMT)
commitc87f10a325378dddf73a267a64fedeff7f3bcc95 (patch)
treeef7154c9bfd7ad4037f734300d9d57fb338920a7
parentc67e4fdc712aa5b818d69b7ef8e3963441febb16 (diff)
downloadjemalloc-c87f10a325378dddf73a267a64fedeff7f3bcc95.zip
jemalloc-c87f10a325378dddf73a267a64fedeff7f3bcc95.tar.gz
jemalloc-c87f10a325378dddf73a267a64fedeff7f3bcc95.tar.bz2
Initialize arenas_tsd before setting it.
Reported by: Ethan Burns, Rich Prohaska, Tudor Bosman
-rw-r--r--src/jemalloc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index fd8bf52..fd6b890 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -769,6 +769,14 @@ malloc_init_hard(void)
}
#endif
+ if (malloc_mutex_init(&arenas_lock))
+ return (true);
+
+ if (pthread_key_create(&arenas_tsd, arenas_cleanup) != 0) {
+ malloc_mutex_unlock(&init_lock);
+ return (true);
+ }
+
/*
* Create enough scaffolding to allow recursive allocation in
* malloc_ncpus().
@@ -795,14 +803,6 @@ malloc_init_hard(void)
ARENA_SET(arenas[0]);
arenas[0]->nthreads++;
- if (malloc_mutex_init(&arenas_lock))
- return (true);
-
- if (pthread_key_create(&arenas_tsd, arenas_cleanup) != 0) {
- malloc_mutex_unlock(&init_lock);
- return (true);
- }
-
#ifdef JEMALLOC_PROF
if (prof_boot2()) {
malloc_mutex_unlock(&init_lock);