MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / background_thread_postfork_child

Function background_thread_postfork_child

deps/jemalloc/src/background_thread.c:761–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761void
762background_thread_postfork_child(tsdn_t *tsdn) {
763 for (unsigned i = 0; i < max_background_threads; i++) {
764 malloc_mutex_postfork_child(tsdn,
765 &background_thread_info[i].mtx);
766 }
767 malloc_mutex_postfork_child(tsdn, &background_thread_lock);
768 if (!background_thread_enabled_at_fork) {
769 return;
770 }
771
772 /* Clear background_thread state (reset to disabled for child). */
773 malloc_mutex_lock(tsdn, &background_thread_lock);
774 n_background_threads = 0;
775 background_thread_enabled_set(tsdn, false);
776 for (unsigned i = 0; i < max_background_threads; i++) {
777 background_thread_info_t *info = &background_thread_info[i];
778 malloc_mutex_lock(tsdn, &info->mtx);
779 info->state = background_thread_stopped;
780 int ret = pthread_cond_init(&info->cond, NULL);
781 assert(ret == 0);
782 background_thread_info_init(tsdn, info);
783 malloc_mutex_unlock(tsdn, &info->mtx);
784 }
785 malloc_mutex_unlock(tsdn, &background_thread_lock);
786}
787
788bool
789background_thread_stats_read(tsdn_t *tsdn, background_thread_stats_t *stats) {

Callers 2

jemalloc_postfork_childFunction · 0.70

Calls 5

malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected