Commit 2f8fc37d authored by jamesge's avatar jamesge

not register pthread_atfork in child process

parent e3840c18
......@@ -43,6 +43,10 @@ struct CombineSampler {
}
};
// True iff pthread_atfork was called. The callback to atfork works for child
// of child as well, no need to register in the child again.
static bool registered_atfork = false;
// Call take_sample() of all scheduled samplers.
// This can be done with regular timer thread, but it's way too slow(global
// contention + log(N) heap manipulations). We need it to be super fast so that
......@@ -88,7 +92,10 @@ private:
LOG(FATAL) << "Fail to create sampling_thread, " << berror(rc);
} else {
_created = true;
pthread_atfork(NULL, NULL, child_callback_atfork);
if (!registered_atfork) {
registered_atfork = true;
pthread_atfork(NULL, NULL, child_callback_atfork);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment