trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From duke8...@apache.org
Subject [trafficserver] branch master updated: move the cv outside of the if, also move the back door startup to avoid health check issues due to the delay
Date Mon, 26 Mar 2018 18:19:58 GMT
This is an automated email from the ASF dual-hosted git repository.

duke8253 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 109f058  move the cv outside of the if, also move the back door startup to avoid
health check issues due to the delay
109f058 is described below

commit 109f0585ca8e732d5e3e2fa71926a138c43e93f7
Author: Fei Deng <duke8253@gmail.com>
AuthorDate: Mon Mar 26 09:58:13 2018 -0500

    move the cv outside of the if, also move the back door startup to avoid health check issues
due to the delay
---
 proxy/Main.cc                     | 20 ++++++++++++++++----
 proxy/http/HttpProxyServerMain.cc |  8 --------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/proxy/Main.cc b/proxy/Main.cc
index 1d07788..e58b6d0 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1802,6 +1802,8 @@ main(int /* argc ATS_UNUSED */, const char **argv)
   netProcessor.init();
   prep_HttpProxyServer();
 
+  // If num_accept_threads == 0, let the ET_NET threads to set the condition variable,
+  // Else we set it here so when checking the condition variable later it returns immediately.
   if (num_accept_threads == 0) {
     eventProcessor.schedule_spawn(&init_HttpProxyServer, ET_NET);
   } else {
@@ -1943,17 +1945,27 @@ main(int /* argc ATS_UNUSED */, const char **argv)
       int delay_p = 0;
       REC_ReadConfigInteger(delay_p, "proxy.config.http.wait_for_cache");
 
+      // Check the condition variable.
+      {
+        std::unique_lock<std::mutex> lock(proxyServerMutex);
+        proxyServerCheck.wait(lock, [] { return et_net_threads_ready; });
+      }
+
       // Delay only if config value set and flag value is zero
       // (-1 => cache already initialized)
       if (delay_p && ink_atomic_cas(&delay_listen_for_cache_p, 0, 1)) {
         Debug("http_listen", "Delaying listen, waiting for cache initialization");
       } else {
-        // Use a condition variable to check if we are ready to call
-        // start_HttpProxyServer() when num_accept_threads is set to 0.
-        std::unique_lock<std::mutex> lock(proxyServerMutex);
-        proxyServerCheck.wait(lock, [] { return et_net_threads_ready; });
         start_HttpProxyServer(); // PORTS_READY_HOOK called from in here
       }
+
+      // Start the back door, since it's just a special HttpProxyServer,
+      // the requirements to start it have been met if we got here.
+      int back_door_port = NO_FD;
+      REC_ReadConfigInteger(back_door_port, "proxy.config.process_manager.mgmt_port");
+      if (back_door_port != NO_FD) {
+        start_HttpProxyServerBackDoor(back_door_port, !!num_accept_threads); // One accept
thread is enough
+      }
     }
     SNIConfig::cloneProtoSet();
     // Plugins can register their own configuration names so now after they've done that
diff --git a/proxy/http/HttpProxyServerMain.cc b/proxy/http/HttpProxyServerMain.cc
index e4dce2d..56ea50a 100644
--- a/proxy/http/HttpProxyServerMain.cc
+++ b/proxy/http/HttpProxyServerMain.cc
@@ -347,14 +347,6 @@ start_HttpProxyServer()
     hook->invoke(TS_EVENT_LIFECYCLE_PORTS_READY, nullptr);
     hook = hook->next();
   }
-
-  // Start the back door, since it's just a special HttpProxyServer,
-  // the requirements to start it has been met if we got here.
-  int back_door_port = NO_FD;
-  REC_ReadConfigInteger(back_door_port, "proxy.config.process_manager.mgmt_port");
-  if (back_door_port != NO_FD) {
-    start_HttpProxyServerBackDoor(back_door_port, !!num_accept_threads); // One accept thread
is enough
-  }
 }
 
 void

-- 
To stop receiving notification emails like this one, please contact
duke8253@apache.org.

Mime
View raw message