mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
TSD: Add fork support to tsd_nominal_tsds.
In case of multithreaded fork, we want to leave the child in a reasonable state, in which tsd_nominal_tsds is either empty or contains only the forking thread.
This commit is contained in:
committed by
David Goldblatt
parent
013ab26c86
commit
41b7372ead
20
src/tsd.c
20
src/tsd.c
@@ -509,3 +509,23 @@ tsd_init_finish(tsd_init_head_t *head, tsd_init_block_t *block) {
|
||||
malloc_mutex_unlock(TSDN_NULL, &head->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
tsd_prefork(tsd_t *tsd) {
|
||||
malloc_mutex_prefork(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
void
|
||||
tsd_postfork_parent(tsd_t *tsd) {
|
||||
malloc_mutex_postfork_parent(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
void
|
||||
tsd_postfork_child(tsd_t *tsd) {
|
||||
malloc_mutex_postfork_child(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
ql_new(&tsd_nominal_tsds);
|
||||
|
||||
if (tsd_state_get(tsd) <= tsd_state_nominal_max) {
|
||||
tsd_add_nominal(tsd);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user