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

zwoop 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 0d55280  Adds the log tag cqint for internal requests
0d55280 is described below

commit 0d55280c07bd54a2438c9a9ffc901372b1975c97
Author: Leif Hedstrom <[email protected]>
AuthorDate: Thu Oct 18 17:33:06 2018 -0600

    Adds the log tag cqint for internal requests
---
 doc/admin-guide/logging/formatting.en.rst | 25 +++++++++++++++----------
 proxy/http/HttpSM.cc                      | 12 +++++-------
 proxy/http/HttpSM.h                       |  1 +
 proxy/logging/Log.cc                      |  5 +++++
 proxy/logging/LogAccess.cc                | 27 ++++++++++++---------------
 proxy/logging/LogAccess.h                 |  1 +
 6 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/doc/admin-guide/logging/formatting.en.rst 
b/doc/admin-guide/logging/formatting.en.rst
index 5295d6b..1a4bce0 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -528,20 +528,25 @@ Plugin Details
 
 .. _piid:
 .. _pitag:
+.. _cqint:
 
 Logging fields which may be used to obtain details of plugins involved in the
 transaction.
 
-===== ============ ============================================================
-Field Source       Description
-===== ============ ============================================================
-piid  Proxy Plugin Plugin ID for the current transaction. This is set for
-                   plugin driven transactions via
-                   :c:func:`TSHttpConnectWithPluginId`.
-pitag Proxy Plugin Plugin tag for the current transaction. This is set for
-                   plugin driven transactions via
-                   :c:func:`TSHttpConnectWithPluginId`.
-===== ============ ============================================================
+===== ================ 
============================================================
+Field Source           Description
+===== ================ 
============================================================
+piid  Proxy Plugin     Plugin ID for the current transaction. This is set for
+                       plugin driven transactions via
+                       :c:func:`TSHttpConnectWithPluginId`.
+pitag Proxy Plugin     Plugin tag for the current transaction. This is set for
+                       plugin driven transactions via
+                       :c:func:`TSHttpConnectWithPluginId`.
+cqint Client Request   If a request was generated internally (via a plugin), 
then
+                       this has a value of ``1``, otherwise ``0``. This can be
+                       useful when tracking internal only requests, such as 
those
+                       generated by the ``authproxy`` plugin.
+===== ================ 
============================================================
 
 .. _admin-logging-fields-proto:
 
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 5b0fa9a..81ec27f 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -460,10 +460,13 @@ HttpSM::attach_client_session(ProxyClientTransaction 
*client_vc, IOBufferReader
   _client_transaction_id = ua_txn->get_transaction_id();
   {
     auto p = ua_txn->get_parent();
+
     if (p) {
       _client_connection_id = p->connection_id();
     }
   }
+  // We've already verified that the netvc is !nullptr above, and netvc == 
ua_txn->get_netvc()
+  is_internal = netvc->get_is_internal_request();
 
   // Collect log & stats information
   client_tcp_reused         = !(ua_txn->is_first_transaction());
@@ -3274,13 +3277,8 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer 
*c)
     //   set the ua_txn into half close mode
 
     // only external POSTs should be subject to this logic; ruling out 
internal POSTs here
-    bool is_eligible_post_request = (t_state.method == HTTP_WKSIDX_POST);
-    if (is_eligible_post_request) {
-      NetVConnection *vc = ua_txn->get_netvc();
-      if (vc) {
-        is_eligible_post_request &= !vc->get_is_internal_request();
-      }
-    }
+    bool is_eligible_post_request = ((t_state.method == HTTP_WKSIDX_POST) && 
!is_internal);
+
     if ((is_eligible_post_request || t_state.client_info.pipeline_possible == 
true) && c->producer->vc_type != HT_STATIC &&
         event == VC_EVENT_WRITE_COMPLETE) {
       ua_txn->set_half_close_flag(true);
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 21f7071..8ceb79e 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -539,6 +539,7 @@ public:
   // Info about client's SSL connection.
   bool client_ssl_reused          = false;
   bool client_connection_is_ssl   = false;
+  bool is_internal                = false;
   const char *client_protocol     = "-";
   const char *client_sec_protocol = "-";
   const char *client_cipher_suite = "-";
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 2e6d8fa..b3a2354 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -497,6 +497,11 @@ Log::init_fields()
   global_field_list.add(field, false);
   field_symbol_hash.emplace("cqssr", field);
 
+  field = new LogField("client_req_is_internal", "cqint", LogField::sINT, 
&LogAccess::marshal_client_req_is_internal,
+                       &LogAccess::unmarshal_int_to_str);
+  global_field_list.add(field, false);
+  field_symbol_hash.emplace("cqint", field);
+
   field = new LogField("client_sec_protocol", "cqssv", LogField::STRING, 
&LogAccess::marshal_client_security_protocol,
                        (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
   global_field_list.add(field, false);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index a9a6fe7..ab1f4a4 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -1689,37 +1689,34 @@ int
 LogAccess::marshal_client_req_tcp_reused(char *buf)
 {
   if (buf) {
-    int64_t tcp_reused;
-    tcp_reused = m_http_sm->client_tcp_reused;
-    marshal_int(buf, tcp_reused);
+    marshal_int(buf, m_http_sm->client_tcp_reused ? 1 : 0);
   }
   return INK_MIN_ALIGN;
 }
 
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
 int
 LogAccess::marshal_client_req_is_ssl(char *buf)
 {
   if (buf) {
-    int64_t is_ssl;
-    is_ssl = m_http_sm->client_connection_is_ssl;
-    marshal_int(buf, is_ssl);
+    marshal_int(buf, m_http_sm->client_connection_is_ssl ? 1 : 0);
   }
   return INK_MIN_ALIGN;
 }
 
-/*-------------------------------------------------------------------------
-  -------------------------------------------------------------------------*/
-
 int
 LogAccess::marshal_client_req_ssl_reused(char *buf)
 {
   if (buf) {
-    int64_t ssl_session_reused;
-    ssl_session_reused = m_http_sm->client_ssl_reused;
-    marshal_int(buf, ssl_session_reused);
+    marshal_int(buf, m_http_sm->client_ssl_reused ? 1 : 0);
+  }
+  return INK_MIN_ALIGN;
+}
+
+int
+LogAccess::marshal_client_req_is_internal(char *buf)
+{
+  if (buf) {
+    marshal_int(buf, m_http_sm->is_internal ? 1 : 0);
   }
   return INK_MIN_ALIGN;
 }
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index fa221ca..2436178 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -149,6 +149,7 @@ public:
   inkcoreapi int marshal_client_req_tcp_reused(char *);         // INT
   inkcoreapi int marshal_client_req_is_ssl(char *);             // INT
   inkcoreapi int marshal_client_req_ssl_reused(char *);         // INT
+  inkcoreapi int marshal_client_req_is_internal(char *);        // INT
   inkcoreapi int marshal_client_security_protocol(char *);      // STR
   inkcoreapi int marshal_client_security_cipher_suite(char *);  // STR
   inkcoreapi int marshal_client_finish_status_code(char *);     // INT

Reply via email to