Handle log_mtx during forking

This commit is contained in:
Yinan Zhang 2019-12-20 10:38:05 -08:00
parent ea42174d07
commit 112dc36dd5
3 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,8 @@
#include "jemalloc/internal/mutex.h"
extern malloc_mutex_t log_mtx;
void prof_try_log(tsd_t *tsd, size_t usize, prof_info_t *prof_info);
bool prof_log_init(tsd_t *tsdn);
#ifdef JEMALLOC_JET

View File

@ -1119,6 +1119,7 @@ prof_prefork0(tsdn_t *tsdn) {
for (i = 0; i < PROF_NTDATA_LOCKS; i++) {
malloc_mutex_prefork(tsdn, &tdata_locks[i]);
}
malloc_mutex_prefork(tsdn, &log_mtx);
for (i = 0; i < PROF_NCTX_LOCKS; i++) {
malloc_mutex_prefork(tsdn, &gctx_locks[i]);
}
@ -1150,6 +1151,7 @@ prof_postfork_parent(tsdn_t *tsdn) {
for (i = 0; i < PROF_NCTX_LOCKS; i++) {
malloc_mutex_postfork_parent(tsdn, &gctx_locks[i]);
}
malloc_mutex_postfork_parent(tsdn, &log_mtx);
for (i = 0; i < PROF_NTDATA_LOCKS; i++) {
malloc_mutex_postfork_parent(tsdn, &tdata_locks[i]);
}
@ -1172,6 +1174,7 @@ prof_postfork_child(tsdn_t *tsdn) {
for (i = 0; i < PROF_NCTX_LOCKS; i++) {
malloc_mutex_postfork_child(tsdn, &gctx_locks[i]);
}
malloc_mutex_postfork_child(tsdn, &log_mtx);
for (i = 0; i < PROF_NTDATA_LOCKS; i++) {
malloc_mutex_postfork_child(tsdn, &tdata_locks[i]);
}

View File

@ -104,7 +104,7 @@ static prof_alloc_node_t *log_alloc_first = NULL;
static prof_alloc_node_t *log_alloc_last = NULL;
/* Protects the prof_logging_state and any log_{...} variable. */
static malloc_mutex_t log_mtx;
malloc_mutex_t log_mtx;
/******************************************************************************/
/*