Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ pub fn init_handler(
env_logger::init();
// after this point we should be able to use all the log macros

PROFILER.set(Profiler::new(version)).unwrap();
// get_or_init: creates Profiler only on first init, reuses on subsequent cycles
PROFILER.get_or_init(|| Profiler::new(version));
// Always spawn daemon when INIT_FLAG=0 (daemon was stopped on last finalize)
PROFILER.get().unwrap().spawn_daemon();
}
*lg += 1;
Expand All @@ -412,7 +414,9 @@ pub fn init_handler_v4(
if config::CONFIG.telemetry_mode > 0 {
let mut lg = INIT_FLAG.lock().unwrap();
if *lg == 0 {
PROFILER.set(Profiler::new(version)).unwrap();
// get_or_init: creates Profiler only on first init, reuses on subsequent cycles
PROFILER.get_or_init(|| Profiler::new(version));
// Always spawn daemon when INIT_FLAG=0 (daemon was stopped on last finalize)
PROFILER.get().unwrap().spawn_daemon();
}
*lg += 1;
Expand Down