This is an automated email from the ASF dual-hosted git repository. bcall 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 d9e01f2 Eliminates expensive librecords and malloc on drain d9e01f2 is described below commit d9e01f278424e1b520fa8b805dcc1008d838361d Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Wed Jan 16 18:46:33 2019 -0700 Eliminates expensive librecords and malloc on drain --- 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 9637a9a..7e1d039 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: @@ -152,11 +155,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 b2753c8..79e534f 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[] = { @@ -284,6 +287,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; }