@@ -10,30 +10,32 @@ pub(crate) unsafe fn startup() {
10
10
}
11
11
12
12
extern "C" fn prepare ( ) {
13
- trace ! ( "Preparing profiler for upcomming fork call." ) ;
14
-
15
13
// Hold mutexes across the handler. If there are any spurious wakeups by
16
14
// the threads while the fork is occurring, they cannot acquire locks
17
15
// since this thread holds them, preventing a deadlock situation.
18
16
if let Some ( profiler) = Profiler :: get ( ) {
17
+ trace ! ( "Preparing profiler for upcomming fork call." ) ;
19
18
let _ = profiler. fork_prepare ( ) ;
20
19
}
21
20
}
22
21
23
22
extern "C" fn parent ( ) {
24
- trace ! ( "Re-enabling profiler in parent after fork call." ) ;
25
23
if let Some ( profiler) = Profiler :: get ( ) {
24
+ trace ! ( "Re-enabling profiler in parent after fork call." ) ;
26
25
profiler. post_fork_parent ( ) ;
27
26
}
28
27
}
29
28
30
29
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
+ }
31
36
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.
37
39
Profiler :: kill ( ) ;
38
40
39
41
alloc_prof_rshutdown ( ) ;
0 commit comments