Skip to content

Commit d35c037

Browse files
committed
Clear tcache_ql after fork in child.
1 parent 9b1befa commit d35c037

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/arena.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,23 @@ void
21332133
arena_postfork_child(tsdn_t *tsdn, arena_t *arena) {
21342134
unsigned i;
21352135

2136+
atomic_store_u(&arena->nthreads[0], 0, ATOMIC_RELAXED);
2137+
atomic_store_u(&arena->nthreads[1], 0, ATOMIC_RELAXED);
2138+
if (tsd_arena_get(tsdn_tsd(tsdn)) == arena) {
2139+
arena_nthreads_inc(arena, false);
2140+
}
2141+
if (tsd_iarena_get(tsdn_tsd(tsdn)) == arena) {
2142+
arena_nthreads_inc(arena, true);
2143+
}
2144+
if (config_stats) {
2145+
ql_new(&arena->tcache_ql);
2146+
tcache_t *tcache = tcache_get(tsdn_tsd(tsdn));
2147+
if (tcache != NULL && tcache->arena == arena) {
2148+
ql_elm_new(tcache, link);
2149+
ql_tail_insert(&arena->tcache_ql, tcache, link);
2150+
}
2151+
}
2152+
21362153
for (i = 0; i < NBINS; i++) {
21372154
malloc_mutex_postfork_child(tsdn, &arena->bins[i].lock);
21382155
}

0 commit comments

Comments
 (0)