This is an automated email from the ASF dual-hosted git repository. sorber pushed a commit to branch 6.2.x in repository https://git-dual.apache.org/repos/asf/trafficserver.git
commit 58c7bc79e235991bbf546935aa6b4dfd9d26c4f2 Author: Susan Hinrichs <[email protected]> AuthorDate: Mon Sep 26 18:32:20 2016 +0000 TS-4892: Wrong metric for proxy.process.http.current_active_client_connections. (cherry picked from commit 2bbb4ed729e00cf40e07b9ca7868f06217b037da) Conflicts: proxy/ProxyClientTransaction.cc --- proxy/ProxyClientSession.cc | 20 +++++++++++++++++++- proxy/ProxyClientSession.h | 9 +++++++++ proxy/ProxyClientTransaction.cc | 3 ++- proxy/ProxyClientTransaction.h | 20 +++++++++++++++----- proxy/http/Http1ClientSession.cc | 11 +++-------- proxy/http/Http1ClientTransaction.cc | 5 +---- proxy/http/HttpSM.cc | 5 +---- proxy/http2/Http2ConnectionState.cc | 6 ++++++ 8 files changed, 56 insertions(+), 23 deletions(-) diff --git a/proxy/ProxyClientSession.cc b/proxy/ProxyClientSession.cc index 982ebae..3ed44ea 100644 --- a/proxy/ProxyClientSession.cc +++ b/proxy/ProxyClientSession.cc @@ -28,11 +28,29 @@ static int64_t next_cs_id = 0; ProxyClientSession::ProxyClientSession() - : VConnection(NULL), acl_record(NULL), host_res_style(HOST_RES_IPV4), debug_on(false), hooks_on(true), con_id(0) + : VConnection(NULL), acl_record(NULL), host_res_style(HOST_RES_IPV4), debug_on(false), hooks_on(true), con_id(0), m_active(false) { ink_zero(this->user_args); } +void +ProxyClientSession::set_session_active() +{ + if (!m_active) { + m_active = true; + HTTP_INCREMENT_DYN_STAT(http_current_active_client_connections_stat); + } +} + +void +ProxyClientSession::clear_session_active() +{ + if (m_active) { + m_active = false; + HTTP_DECREMENT_DYN_STAT(http_current_active_client_connections_stat); + } +} + int64_t ProxyClientSession::next_connection_id() { diff --git a/proxy/ProxyClientSession.h b/proxy/ProxyClientSession.h index f0ce7e0..ed5b1d6 100644 --- a/proxy/ProxyClientSession.h +++ b/proxy/ProxyClientSession.h @@ -177,6 +177,9 @@ public: { } + void set_session_active(); + void clear_session_active(); + protected: // XXX Consider using a bitwise flags variable for the following flags, so that we can make the best // use of internal alignment padding. @@ -202,6 +205,12 @@ private: void handle_api_return(int event); + // for DI. An active connection is one that a request has + // been successfully parsed (PARSE_DONE) and it remains to + // be active until the transaction goes through or the client + // aborts. + bool m_active; + friend void TSHttpSsnDebugSet(TSHttpSsn, int); }; diff --git a/proxy/ProxyClientTransaction.cc b/proxy/ProxyClientTransaction.cc index 8827171..3371916 100644 --- a/proxy/ProxyClientTransaction.cc +++ b/proxy/ProxyClientTransaction.cc @@ -27,7 +27,8 @@ #define DebugHttpTxn(fmt, ...) DebugSsn(this, "http_txn", fmt, __VA_ARGS__) -ProxyClientTransaction::ProxyClientTransaction() : VConnection(NULL), parent(NULL), current_reader(NULL), restart_immediate(false) +ProxyClientTransaction::ProxyClientTransaction() + : VConnection(NULL), parent(NULL), current_reader(NULL), sm_reader(NULL), host_res_style(HOST_RES_NONE), restart_immediate(false) { } diff --git a/proxy/ProxyClientTransaction.h b/proxy/ProxyClientTransaction.h index 4ccf000..bb4ea7c 100644 --- a/proxy/ProxyClientTransaction.h +++ b/proxy/ProxyClientTransaction.h @@ -103,11 +103,21 @@ public: return parent->has_hooks(); } - // for DI. An active connection is one that a request has - // been successfully parsed (PARSE_DONE) and it remains to - // be active until the transaction goes through or the client - // aborts. - bool m_active; + virtual void + set_session_active() + { + if (parent) { + parent->set_session_active(); + } + } + + virtual void + clear_session_active() + { + if (parent) { + parent->clear_session_active(); + } + } /// DNS resolution preferences. HostResStyle diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc index b9f3816..78a0614 100644 --- a/proxy/http/Http1ClientSession.cc +++ b/proxy/http/Http1ClientSession.cc @@ -241,10 +241,7 @@ Http1ClientSession::do_io_close(int alerrno) if (read_state == HCS_CLOSED) return; // Don't double call session close if (read_state == HCS_ACTIVE_READER) { - if (trans.m_active) { - trans.m_active = false; - HTTP_DECREMENT_DYN_STAT(http_current_active_client_connections_stat); - } + clear_session_active(); } // Prevent double closing @@ -488,10 +485,8 @@ Http1ClientSession::attach_server_session(HttpServerSession *ssession, bool tran ink_assert(ssession->get_netvc() != this->get_netvc()); // handling potential keep-alive here - if (trans.m_active) { - trans.m_active = false; - HTTP_DECREMENT_DYN_STAT(http_current_active_client_connections_stat); - } + clear_session_active(); + // Since this our slave, issue an IO to detect a close and // have it call the client session back. This IO also prevent // the server net conneciton from calling back a dead sm diff --git a/proxy/http/Http1ClientTransaction.cc b/proxy/http/Http1ClientTransaction.cc index cb0de3e..2220e60 100644 --- a/proxy/http/Http1ClientTransaction.cc +++ b/proxy/http/Http1ClientTransaction.cc @@ -33,10 +33,7 @@ Http1ClientTransaction::release(IOBufferReader *r) MgmtInt ka_in = current_reader->t_state.txn_conf->keep_alive_no_activity_timeout_in; set_inactivity_timeout(HRTIME_SECONDS(ka_in)); - if (m_active) { - m_active = false; - HTTP_DECREMENT_DYN_STAT(http_current_active_client_connections_stat); - } + parent->clear_session_active(); parent->ssn_last_txn_time = Thread::get_hrtime(); // Make sure that the state machine is returning diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 420eef8..d542553 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -768,10 +768,7 @@ HttpSM::state_read_client_request_header(int event, void *data) case PARSE_DONE: DebugSM("http", "[%" PRId64 "] done parsing client request header", sm_id); - if (ua_session->m_active == false) { - ua_session->m_active = true; - HTTP_INCREMENT_DYN_STAT(http_current_active_client_connections_stat); - } + ua_session->set_session_active(); if (t_state.hdr_info.client_request.version_get() == HTTPVersion(1, 1) && (t_state.hdr_info.client_request.method_get_wksidx() == HTTP_WKSIDX_POST || diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index cc45a8c..8dcec8c 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -971,6 +971,12 @@ Http2ConnectionState::release_stream(Http2Stream *stream) if (stream) { --total_client_streams_count; } + + // If the number of clients is 0, then mark the connection as inactive + if (total_client_streams_count == 0 && ua_session) { + ua_session->clear_session_active(); + } + if (ua_session && fini_received && total_client_streams_count == 0) { // We were shutting down, go ahead and terminate the session ua_session->destroy(); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
