| 3852 | |
| 3853 | #ifndef JEMALLOC_MUTEX_INIT_CB |
| 3854 | void |
| 3855 | jemalloc_postfork_parent(void) |
| 3856 | #else |
| 3857 | JEMALLOC_EXPORT void |
| 3858 | _malloc_postfork(void) |
| 3859 | #endif |
| 3860 | { |
| 3861 | tsd_t *tsd; |
| 3862 | unsigned i, narenas; |
| 3863 | |
| 3864 | #ifdef JEMALLOC_MUTEX_INIT_CB |
| 3865 | if (!malloc_initialized()) { |
| 3866 | return; |
| 3867 | } |
| 3868 | #endif |
| 3869 | assert(malloc_initialized()); |
| 3870 | |
| 3871 | tsd = tsd_fetch(); |
| 3872 | |
| 3873 | tsd_postfork_parent(tsd); |
| 3874 | |
| 3875 | witness_postfork_parent(tsd_witness_tsdp_get(tsd)); |
| 3876 | /* Release all mutexes, now that fork() has completed. */ |
| 3877 | for (i = 0, narenas = narenas_total_get(); i < narenas; i++) { |
| 3878 | arena_t *arena; |
| 3879 | |
| 3880 | if ((arena = arena_get(tsd_tsdn(tsd), i, false)) != NULL) { |
| 3881 | arena_postfork_parent(tsd_tsdn(tsd), arena); |
| 3882 | } |
| 3883 | } |
| 3884 | prof_postfork_parent(tsd_tsdn(tsd)); |
| 3885 | if (have_background_thread) { |
| 3886 | background_thread_postfork_parent(tsd_tsdn(tsd)); |
| 3887 | } |
| 3888 | malloc_mutex_postfork_parent(tsd_tsdn(tsd), &arenas_lock); |
| 3889 | tcache_postfork_parent(tsd_tsdn(tsd)); |
| 3890 | ctl_postfork_parent(tsd_tsdn(tsd)); |
| 3891 | } |
| 3892 | |
| 3893 | void |
| 3894 | jemalloc_postfork_child(void) { |
no test coverage detected