Fix forkable repeated registration (#30642)

This fixes a bug that could occur on repeated grpc initialization (after a complete shutdown)

Fixes #30640
pull/30665/head
AJ Heller 2 years ago committed by GitHub
parent c7ea4a2ee7
commit dda793ffa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/lib/event_engine/forkable.cc

@ -41,8 +41,9 @@ Forkable::~Forkable() { StopManagingForkable(this); }
void RegisterForkHandlers() { void RegisterForkHandlers() {
grpc_core::MutexLock lock(g_mu.get()); grpc_core::MutexLock lock(g_mu.get());
GPR_ASSERT(!absl::exchange(g_registered, true)); if (!absl::exchange(g_registered, true)) {
pthread_atfork(PrepareFork, PostforkParent, PostforkChild); pthread_atfork(PrepareFork, PostforkParent, PostforkChild);
}
}; };
void PrepareFork() { void PrepareFork() {

Loading…
Cancel
Save