diff options
author | Jason Evans <je@fb.com> | 2014-10-08 07:54:16 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2014-10-08 07:54:16 (GMT) |
commit | 3a8b9b1fd95b1bb9b3dc00f6798eeb40d5100b7b (patch) | |
tree | 02fc21077f1cb83955bdb650f193b4f156170bcd | |
parent | f22214a29ddd3bed005cbcc8f2aff7c61ef4940b (diff) | |
download | jemalloc-3a8b9b1fd95b1bb9b3dc00f6798eeb40d5100b7b.zip jemalloc-3a8b9b1fd95b1bb9b3dc00f6798eeb40d5100b7b.tar.gz jemalloc-3a8b9b1fd95b1bb9b3dc00f6798eeb40d5100b7b.tar.bz2 |
Fix a recursive lock acquisition regression.
Fix a recursive lock acquisition regression, which was introduced by
8bb3198f72fc7587dc93527f9f19fb5be52fa553 (Refactor/fix arenas
manipulation.).
-rw-r--r-- | src/jemalloc.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index 38b5aaf..c62d8ce 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -244,13 +244,11 @@ a0free(void *ptr) } /* Create a new arena and insert it into the arenas array at index ind. */ -arena_t * -arena_init(unsigned ind) +static arena_t * +arena_init_locked(unsigned ind) { arena_t *arena; - malloc_mutex_lock(&arenas_lock); - /* Expand arenas if necessary. */ assert(ind <= narenas_total); if (ind == narenas_total) { @@ -258,10 +256,8 @@ arena_init(unsigned ind) arena_t **arenas_new = (arena_t **)a0malloc(CACHELINE_CEILING(narenas_new * sizeof(arena_t *))); - if (arenas_new == NULL) { - arena = NULL; - goto label_return; - } + if (arenas_new == NULL) + return (NULL); memcpy(arenas_new, arenas, narenas_total * sizeof(arena_t *)); arenas_new[ind] = NULL; /* @@ -281,12 +277,21 @@ arena_init(unsigned ind) arena = arenas[ind]; if (arena != NULL) { assert(ind < narenas_auto); - goto label_return; + return (arena); } /* Actually initialize the arena. */ arena = arenas[ind] = arena_new(ind); -label_return: + return (arena); +} + +arena_t * +arena_init(unsigned ind) +{ + arena_t *arena; + + malloc_mutex_lock(&arenas_lock); + arena = arena_init_locked(ind); malloc_mutex_unlock(&arenas_lock); return (arena); } @@ -477,7 +482,7 @@ arena_choose_hard(tsd_t *tsd) } else { /* Initialize a new arena. */ choose = first_null; - ret = arena_init(choose); + ret = arena_init_locked(choose); if (ret == NULL) { malloc_mutex_unlock(&arenas_lock); return (NULL); |