aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/patches/pr33085_fix_epoll1_engine_reinit.patch
blob: d98bdce022bb98d6046b5d5853dac848afc340af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- 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;
 }