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

Function prof_log_start

deps/jemalloc/src/prof.c:2516–2549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2514#endif
2515
2516bool
2517prof_log_start(tsdn_t *tsdn, const char *filename) {
2518 if (!opt_prof || !prof_booted) {
2519 return true;
2520 }
2521
2522 bool ret = false;
2523 size_t buf_size = PATH_MAX + 1;
2524
2525 malloc_mutex_lock(tsdn, &log_mtx);
2526
2527 if (prof_logging_state != prof_logging_state_stopped) {
2528 ret = true;
2529 } else if (filename == NULL) {
2530 /* Make default name. */
2531 malloc_snprintf(log_filename, buf_size, "%s.%d.%"FMTu64".json",
2532 opt_prof_prefix, prof_getpid(), log_seq);
2533 log_seq++;
2534 prof_logging_state = prof_logging_state_started;
2535 } else if (strlen(filename) >= buf_size) {
2536 ret = true;
2537 } else {
2538 strcpy(log_filename, filename);
2539 prof_logging_state = prof_logging_state_started;
2540 }
2541
2542 if (!ret) {
2543 nstime_update(&log_start_timestamp);
2544 }
2545
2546 malloc_mutex_unlock(tsdn, &log_mtx);
2547
2548 return ret;
2549}
2550
2551/* Used as an atexit function to stop logging on exit. */
2552static void

Callers 2

prof_log_start_ctlFunction · 0.85
prof_boot2Function · 0.85

Calls 3

prof_getpidFunction · 0.70
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected