You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/10/13 14:47:39 UTC

[trafficserver] branch 7.1.x updated: uses backoff to launch ts if crash was recent

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new 4fe3a66  uses backoff to launch ts if crash was recent
4fe3a66 is described below

commit 4fe3a663011d36b3886a5677596944e8a5732a99
Author: Derek Dagit <de...@oath.com>
AuthorDate: Fri Oct 13 02:48:18 2017 +0000

    uses backoff to launch ts if crash was recent
    
    (cherry picked from commit 2eb7d8b13c2929b0a58bf8b3175b240cf5425399)
    (cherry picked from commit a26aef80a81814bd4b123eb32daaed58c1c0c161)
    (cherry picked from commit b5b1ab7221f8a20cba29bdffcf911ec3d3454144)
---
 cmd/traffic_manager/traffic_manager.cc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc
index d547ca1..d9964f5 100644
--- a/cmd/traffic_manager/traffic_manager.cc
+++ b/cmd/traffic_manager/traffic_manager.cc
@@ -723,7 +723,9 @@ main(int argc, const char **argv)
   metrics_binding_initialize(*binding);
   metrics_binding_configure(*binding);
 
-  int sleep_time = 0; // sleep_time given in sec
+  const int MAX_SLEEP_S      = 60; // Max sleep duration
+  int sleep_time             = 0;  // sleep_time given in sec
+  uint64_t last_start_epoc_s = 0;  // latest start attempt in seconds since epoc
 
   for (;;) {
     lmgmt->processEventQueue();
@@ -800,16 +802,17 @@ main(int argc, const char **argv)
     }
 
     if (lmgmt->run_proxy && !lmgmt->processRunning() && lmgmt->proxy_recoverable) { /* Make sure we still have a proxy up */
-      if (sleep_time) {
+      const uint64_t now = static_cast<uint64_t>(time(nullptr));
+      if (sleep_time && ((now - last_start_epoc_s) < MAX_SLEEP_S)) {
         mgmt_log("Relaunching proxy after %d sec...", sleep_time);
         millisleep(1000 * sleep_time); // we use millisleep instead of sleep because it doesnt interfere with signals
-        sleep_time = (sleep_time > 30) ? 60 : sleep_time * 2;
+        sleep_time = std::min(sleep_time * 2, MAX_SLEEP_S);
       } else {
         sleep_time = 1;
       }
       if (ProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_NONE) == TS_ERR_OKAY) {
-        just_started = 0;
-        sleep_time   = 0;
+        just_started      = 0;
+        last_start_epoc_s = static_cast<uint64_t>(time(nullptr));
       } else {
         just_started++;
       }

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].