Do proper cleanup for tsd_state_reincarnated.
Also enable arena_bind under non-nominal state, as the cleanup will be handled correctly now.
This commit is contained in:
@@ -422,13 +422,7 @@ arena_init(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
|
||||
|
||||
static void
|
||||
arena_bind(tsd_t *tsd, unsigned ind, bool internal) {
|
||||
arena_t *arena;
|
||||
|
||||
if (!tsd_nominal(tsd)) {
|
||||
return;
|
||||
}
|
||||
|
||||
arena = arena_get(tsd_tsdn(tsd), ind, false);
|
||||
arena_t *arena = arena_get(tsd_tsdn(tsd), ind, false);
|
||||
arena_nthreads_inc(arena, internal);
|
||||
|
||||
if (internal) {
|
||||
@@ -455,6 +449,7 @@ arena_unbind(tsd_t *tsd, unsigned ind, bool internal) {
|
||||
|
||||
arena = arena_get(tsd_tsdn(tsd), ind, false);
|
||||
arena_nthreads_dec(arena, internal);
|
||||
|
||||
if (internal) {
|
||||
tsd_iarena_set(tsd, NULL);
|
||||
} else {
|
||||
|
15
src/tsd.c
15
src/tsd.c
@@ -86,6 +86,12 @@ tsd_cleanup(void *arg) {
|
||||
/* Do nothing. */
|
||||
break;
|
||||
case tsd_state_nominal:
|
||||
case tsd_state_reincarnated:
|
||||
/*
|
||||
* Reincarnated means another destructor deallocated memory
|
||||
* after this destructor was called. Reset state to
|
||||
* tsd_state_purgatory and request another callback.
|
||||
*/
|
||||
#define MALLOC_TSD_cleanup_yes(n, t) \
|
||||
n##_cleanup(tsd);
|
||||
#define MALLOC_TSD_cleanup_no(n, t)
|
||||
@@ -106,15 +112,6 @@ MALLOC_TSD
|
||||
* nothing, and do not request another callback.
|
||||
*/
|
||||
break;
|
||||
case tsd_state_reincarnated:
|
||||
/*
|
||||
* Another destructor deallocated memory after this destructor
|
||||
* was called. Reset state to tsd_state_purgatory and request
|
||||
* another callback.
|
||||
*/
|
||||
tsd->state = tsd_state_purgatory;
|
||||
tsd_set(tsd);
|
||||
break;
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
|
Reference in New Issue
Block a user