Fix a recursive lock acquisition regression.
Fix a recursive lock acquisition regression, which was introduced by
8bb3198f72
(Refactor/fix arenas
manipulation.).
This commit is contained in:
parent
f22214a29d
commit
3a8b9b1fd9
@ -244,13 +244,11 @@ a0free(void *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new arena and insert it into the arenas array at index ind. */
|
/* Create a new arena and insert it into the arenas array at index ind. */
|
||||||
arena_t *
|
static arena_t *
|
||||||
arena_init(unsigned ind)
|
arena_init_locked(unsigned ind)
|
||||||
{
|
{
|
||||||
arena_t *arena;
|
arena_t *arena;
|
||||||
|
|
||||||
malloc_mutex_lock(&arenas_lock);
|
|
||||||
|
|
||||||
/* Expand arenas if necessary. */
|
/* Expand arenas if necessary. */
|
||||||
assert(ind <= narenas_total);
|
assert(ind <= narenas_total);
|
||||||
if (ind == narenas_total) {
|
if (ind == narenas_total) {
|
||||||
@ -258,10 +256,8 @@ arena_init(unsigned ind)
|
|||||||
arena_t **arenas_new =
|
arena_t **arenas_new =
|
||||||
(arena_t **)a0malloc(CACHELINE_CEILING(narenas_new *
|
(arena_t **)a0malloc(CACHELINE_CEILING(narenas_new *
|
||||||
sizeof(arena_t *)));
|
sizeof(arena_t *)));
|
||||||
if (arenas_new == NULL) {
|
if (arenas_new == NULL)
|
||||||
arena = NULL;
|
return (NULL);
|
||||||
goto label_return;
|
|
||||||
}
|
|
||||||
memcpy(arenas_new, arenas, narenas_total * sizeof(arena_t *));
|
memcpy(arenas_new, arenas, narenas_total * sizeof(arena_t *));
|
||||||
arenas_new[ind] = NULL;
|
arenas_new[ind] = NULL;
|
||||||
/*
|
/*
|
||||||
@ -281,12 +277,21 @@ arena_init(unsigned ind)
|
|||||||
arena = arenas[ind];
|
arena = arenas[ind];
|
||||||
if (arena != NULL) {
|
if (arena != NULL) {
|
||||||
assert(ind < narenas_auto);
|
assert(ind < narenas_auto);
|
||||||
goto label_return;
|
return (arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actually initialize the arena. */
|
/* Actually initialize the arena. */
|
||||||
arena = arenas[ind] = arena_new(ind);
|
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);
|
malloc_mutex_unlock(&arenas_lock);
|
||||||
return (arena);
|
return (arena);
|
||||||
}
|
}
|
||||||
@ -477,7 +482,7 @@ arena_choose_hard(tsd_t *tsd)
|
|||||||
} else {
|
} else {
|
||||||
/* Initialize a new arena. */
|
/* Initialize a new arena. */
|
||||||
choose = first_null;
|
choose = first_null;
|
||||||
ret = arena_init(choose);
|
ret = arena_init_locked(choose);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
malloc_mutex_unlock(&arenas_lock);
|
malloc_mutex_unlock(&arenas_lock);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user