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
commit cc9e266eaf13a21a87305c57af141d6a0de624b9 Author: Bryan Call <bc...@apache.org> AuthorDate: Thu Feb 1 16:17:15 2018 -0800 Fix X-Id logging for slow log (cherry picked from commit 155d1a7af430de72e5b8738ac4b6c16007d11c61) Conflicts: proxy/http/HttpSM.cc --- proxy/http/HttpSM.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index d63bea1..a142125 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -40,16 +40,14 @@ #include "RemapProcessor.h" #include "Transform.h" #include "P_SSLConfig.h" -#include <openssl/ossl_typ.h> -#include <openssl/ssl.h> #include "HttpPages.h" - #include "IPAllow.h" -//#include "I_Auth.h" -//#include "HttpAuthParams.h" -#include "congest/Congestion.h" #include "ts/I_Layout.h" +#include <openssl/ossl_typ.h> +#include <openssl/ssl.h> +#include <algorithm> + using ts::StringView; #define DEFAULT_RESPONSE_BUFFER_SIZE_INDEX 6 // 8K @@ -7054,11 +7052,10 @@ HttpSM::update_stats() if (is_action_tag_set("http_handler_times")) { print_all_http_handler_times(); } - */ + */ // print slow requests if the threshold is set (> 0) and if we are over the time threshold if (t_state.txn_conf->slow_log_threshold != 0 && ink_hrtime_from_msec(t_state.txn_conf->slow_log_threshold) < total_time) { - URL *url = t_state.hdr_info.client_request.url_get(); char url_string[256] = ""; int offset = 0; int skip = 0; @@ -7068,13 +7065,12 @@ HttpSM::update_stats() // unique id char unique_id_string[128] = ""; - // [amc] why do we check the URL to get a MIME field? - if (nullptr != url && url->valid()) { - int length = 0; - const char *field = t_state.hdr_info.client_request.value_get(MIME_FIELD_X_ID, MIME_LEN_X_ID, &length); - if (field != nullptr) { - ink_strlcpy(unique_id_string, field, sizeof(unique_id_string)); - } + int length = 0; + const char *field = t_state.hdr_info.client_request.value_get(MIME_FIELD_X_ID, MIME_LEN_X_ID, &length); + if (field != nullptr && length > 0) { + length = std::min(length, static_cast<int>(sizeof(unique_id_string))); + memcpy(unique_id_string, field, length); + unique_id_string[length] = 0; // NULL terminate the string } // set the fd for the request -- To stop receiving notification emails like this one, please contact zw...@apache.org.