Skip to content

Commit 1616f46

Browse files
fixup
1 parent 76b5da1 commit 1616f46

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

profiling/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pub mod capi;
33
mod clocks;
44
mod config;
55
mod logging;
6-
mod pthread;
76
pub mod profiling;
7+
mod pthread;
88
mod sapi;
99
mod thin_str;
1010
mod wall_time;
@@ -936,4 +936,4 @@ fn notify_trace_finished(local_root_span_id: u64, span_type: Cow<str>, resource:
936936
}
937937
}
938938
});
939-
}
939+
}

profiling/src/pthread.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,32 @@ pub(crate) unsafe fn startup() {
1010
}
1111

1212
extern "C" fn prepare() {
13-
trace!("Preparing profiler for upcomming fork call.");
14-
1513
// Hold mutexes across the handler. If there are any spurious wakeups by
1614
// the threads while the fork is occurring, they cannot acquire locks
1715
// since this thread holds them, preventing a deadlock situation.
1816
if let Some(profiler) = Profiler::get() {
17+
trace!("Preparing profiler for upcomming fork call.");
1918
let _ = profiler.fork_prepare();
2019
}
2120
}
2221

2322
extern "C" fn parent() {
24-
trace!("Re-enabling profiler in parent after fork call.");
2523
if let Some(profiler) = Profiler::get() {
24+
trace!("Re-enabling profiler in parent after fork call.");
2625
profiler.post_fork_parent();
2726
}
2827
}
2928

3029
unsafe extern "C" fn child() {
30+
if let None = Profiler::get() {
31+
// No profiler, so nothing to do. This can happen in Apache forking SAPI, where Apache
32+
// would first go through MINIT phase and then fork(), so we'd observe the fork but there
33+
// is no profiler yet.
34+
return;
35+
}
3136
trace!("Shutting down profiler for child process after fork");
32-
// Disable the profiler because either:
33-
// 1. This is the child, and we don't support this yet.
34-
// 2. Something went wrong, and disable it to be safe.
35-
// And then leak the old profiler. Its drop method is not safe to run in
36-
// these situations.
37+
// Disable the profiler because this is the child, and we don't support this yet.
38+
// And then leak the old profiler. Its drop method is not safe to run in these situations.
3739
Profiler::kill();
3840

3941
alloc_prof_rshutdown();

0 commit comments

Comments
 (0)