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 2019/02/11 20:00:41 UTC

[trafficserver] branch 8.0.x updated: Eliminates expensive librecords and malloc on drain

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

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


The following commit(s) were added to refs/heads/8.0.x by this push:
     new 467959f  Eliminates expensive librecords and malloc on drain
467959f is described below

commit 467959f8358fbd317fed8a9360bd10c51ffd42ca
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed Jan 16 18:46:33 2019 -0700

    Eliminates expensive librecords and malloc on drain
    
    (cherry picked from commit d9e01f278424e1b520fa8b805dcc1008d838361d)
---
 proxy/ProxyClientSession.h           | 9 ++++-----
 src/traffic_server/traffic_server.cc | 8 ++++++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/proxy/ProxyClientSession.h b/proxy/ProxyClientSession.h
index 98e2e12..05e3564 100644
--- a/proxy/ProxyClientSession.h
+++ b/proxy/ProxyClientSession.h
@@ -69,6 +69,9 @@ struct ProxyError {
   uint32_t code       = 0;
 };
 
+// A little ugly, but this global is tracked by traffic_server.
+extern bool ts_is_draining;
+
 class ProxyClientSession : public VConnection
 {
 public:
@@ -153,11 +156,7 @@ public:
   bool
   is_draining() const
   {
-    RecInt draining;
-    if (RecGetRecordInt("proxy.node.config.draining", &draining) != REC_ERR_OKAY) {
-      return false;
-    }
-    return draining != 0;
+    return ts_is_draining;
   }
 
   // Initiate an API hook invocation.
diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc
index f9006b4..26fb015 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -170,6 +170,9 @@ static bool signal_received[NSIG];
 // -1: cache is already initialized, don't delay.
 static int delay_listen_for_cache_p;
 
+// Keeps track if the server is in draining state, follows the proxy.node.config.draining metric
+bool ts_is_draining = false;
+
 AppVersionInfo appVersionInfo; // Build info for this application
 
 static ArgumentDescription argument_descriptions[] = {
@@ -279,6 +282,7 @@ public:
       RecInt timeout = 0;
       if (RecGetRecordInt("proxy.config.stop.shutdown_timeout", &timeout) == REC_ERR_OKAY && timeout) {
         RecSetRecordInt("proxy.node.config.draining", 1, REC_SOURCE_DEFAULT);
+        ts_is_draining = true;
         if (!remote_management_flag) {
           // Close listening sockets here only if TS is running standalone
           RecInt close_sockets = 0;
@@ -2036,8 +2040,8 @@ mgmt_restart_shutdown_callback(void *, char *, int /* data_len ATS_UNUSED */)
 static void *
 mgmt_drain_callback(void *, char *arg, int len)
 {
-  ink_assert(len > 1 && (arg[0] == '0' || arg[0] == '1'));
-  RecSetRecordInt("proxy.node.config.draining", arg[0] == '1', REC_SOURCE_DEFAULT);
+  ts_is_draining = (len == 2 && arg[0] == '1');
+  RecSetRecordInt("proxy.node.config.draining", ts_is_draining ? 1 : 0, REC_SOURCE_DEFAULT);
   return nullptr;
 }