| 3260 | |
| 3261 | #ifndef JEMALLOC_MUTEX_INIT_CB |
| 3262 | void |
| 3263 | jemalloc_postfork_parent(void) |
| 3264 | #else |
| 3265 | JEMALLOC_EXPORT void |
| 3266 | _malloc_postfork(void) |
| 3267 | #endif |
| 3268 | { |
| 3269 | tsd_t *tsd; |
| 3270 | unsigned i, narenas; |
| 3271 | |
| 3272 | #ifdef JEMALLOC_MUTEX_INIT_CB |
| 3273 | if (!malloc_initialized()) { |
| 3274 | return; |
| 3275 | } |
| 3276 | #endif |
| 3277 | assert(malloc_initialized()); |
| 3278 | |
| 3279 | tsd = tsd_fetch(); |
| 3280 | |
| 3281 | witness_postfork_parent(tsd_witness_tsdp_get(tsd)); |
| 3282 | /* Release all mutexes, now that fork() has completed. */ |
| 3283 | for (i = 0, narenas = narenas_total_get(); i < narenas; i++) { |
| 3284 | arena_t *arena; |
| 3285 | |
| 3286 | if ((arena = arena_get(tsd_tsdn(tsd), i, false)) != NULL) { |
| 3287 | arena_postfork_parent(tsd_tsdn(tsd), arena); |
| 3288 | } |
| 3289 | } |
| 3290 | prof_postfork_parent(tsd_tsdn(tsd)); |
| 3291 | if (have_background_thread) { |
| 3292 | background_thread_postfork_parent(tsd_tsdn(tsd)); |
| 3293 | } |
| 3294 | malloc_mutex_postfork_parent(tsd_tsdn(tsd), &arenas_lock); |
| 3295 | tcache_postfork_parent(tsd_tsdn(tsd)); |
| 3296 | ctl_postfork_parent(tsd_tsdn(tsd)); |
| 3297 | } |
| 3298 | |
| 3299 | void |
| 3300 | jemalloc_postfork_child(void) { |
no test coverage detected