--- a/src/core/lib/iomgr/ev_epoll1_linux.cc (index) +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc (working tree) @@ -60,6 +60,7 @@ #include "src/core/lib/iomgr/wakeup_fd_posix.h" static grpc_wakeup_fd global_wakeup_fd; +static bool g_is_shutdown = true; //****************************************************************************** // Singleton epoll set related fields @@ -1230,6 +1231,7 @@ static void shutdown_engine(void) { gpr_mu_destroy(&fork_fd_list_mu); grpc_core::Fork::SetResetChildPollingEngineFunc(nullptr); } + g_is_shutdown = true; } static bool init_epoll1_linux(); @@ -1281,10 +1280,13 @@ is_any_background_poller_thread, /* name = */ "epoll1", - /* check_engine_available = */ [](bool) { return init_epoll1_linux(); }, - /* init_engine = */ []() {}, + /* check_engine_available = */ + [](bool) { return init_epoll1_linux(); }, + /* init_engine = */ + []() { GPR_ASSERT(init_epoll1_linux()); }, shutdown_background_closure, - /* shutdown_engine = */ []() {}, + /* shutdown_engine = */ + []() { shutdown_engine(); }, add_closure_to_background_poller, fd_set_pre_allocated, @@ -1309,6 +1311,7 @@ // Create epoll_fd (epoll_set_init() takes care of that) to make sure epoll // support is available static bool init_epoll1_linux() { + if (!g_is_shutdown) return true; if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping epoll1 because of no wakeup fd."); return false; @@ -1317,6 +1323,7 @@ static bool init_epoll1_linux() { grpc_core::Fork::SetResetChildPollingEngineFunc( reset_event_manager_on_fork); } + g_is_shutdown = false; return true; }