pr33085_fix_epoll1_engine_reinit.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --- a/src/core/lib/iomgr/ev_epoll1_linux.cc (index)
  2. +++ b/src/core/lib/iomgr/ev_epoll1_linux.cc (working tree)
  3. @@ -60,6 +60,7 @@
  4. #include "src/core/lib/iomgr/wakeup_fd_posix.h"
  5. static grpc_wakeup_fd global_wakeup_fd;
  6. +static bool g_is_shutdown = true;
  7. //******************************************************************************
  8. // Singleton epoll set related fields
  9. @@ -1230,6 +1231,7 @@ static void shutdown_engine(void) {
  10. gpr_mu_destroy(&fork_fd_list_mu);
  11. grpc_core::Fork::SetResetChildPollingEngineFunc(nullptr);
  12. }
  13. + g_is_shutdown = true;
  14. }
  15. static bool init_epoll1_linux();
  16. @@ -1281,10 +1280,13 @@
  17. is_any_background_poller_thread,
  18. /* name = */ "epoll1",
  19. - /* check_engine_available = */ [](bool) { return init_epoll1_linux(); },
  20. - /* init_engine = */ []() {},
  21. + /* check_engine_available = */
  22. + [](bool) { return init_epoll1_linux(); },
  23. + /* init_engine = */
  24. + []() { GPR_ASSERT(init_epoll1_linux()); },
  25. shutdown_background_closure,
  26. - /* shutdown_engine = */ []() {},
  27. + /* shutdown_engine = */
  28. + []() { shutdown_engine(); },
  29. add_closure_to_background_poller,
  30. fd_set_pre_allocated,
  31. @@ -1309,6 +1311,7 @@
  32. // Create epoll_fd (epoll_set_init() takes care of that) to make sure epoll
  33. // support is available
  34. static bool init_epoll1_linux() {
  35. + if (!g_is_shutdown) return true;
  36. if (!grpc_has_wakeup_fd()) {
  37. gpr_log(GPR_ERROR, "Skipping epoll1 because of no wakeup fd.");
  38. return false;
  39. @@ -1317,6 +1323,7 @@ static bool init_epoll1_linux() {
  40. grpc_core::Fork::SetResetChildPollingEngineFunc(
  41. reset_event_manager_on_fork);
  42. }
  43. + g_is_shutdown = false;
  44. return true;
  45. }