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

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

commit c6bc4672ae1b2910e526c864c4dc6fe6eb16170b
Author: Brian Neradt <[email protected]>
AuthorDate: Tue Jun 25 08:58:39 2024 -0500

    HttpSM request tunneling naming updates (#11463)
    
    These are some HttpSM naming and comment changes I made to improve
    readability while working on request body processing. No functionality
    is changed with this PR.
    
    (cherry picked from commit e33f0d32afc84904ee68226a1aeeb859f5182c97)
---
 include/iocore/eventsystem/VIO.h        |  3 +++
 include/iocore/net/NetVConnection.h     |  3 ++-
 include/proxy/http/Http1ClientSession.h |  4 +++-
 include/proxy/http/HttpSM.h             |  5 ++---
 src/proxy/http/Http1ClientSession.cc    |  3 ++-
 src/proxy/http/HttpSM.cc                | 19 ++++++++++---------
 src/proxy/http/HttpTransact.cc          |  2 +-
 7 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/include/iocore/eventsystem/VIO.h b/include/iocore/eventsystem/VIO.h
index a12f12faa8..39c913e35c 100644
--- a/include/iocore/eventsystem/VIO.h
+++ b/include/iocore/eventsystem/VIO.h
@@ -208,6 +208,9 @@ public:
     Internal backpointer to the VConnection for use in the reenable
     functions.
 
+    Despite the name, this may refer to either a client or server side
+    connection.
+
   */
   VConnection *vc_server = nullptr;
 
diff --git a/include/iocore/net/NetVConnection.h 
b/include/iocore/net/NetVConnection.h
index 16a9b89341..ff38f853aa 100644
--- a/include/iocore/net/NetVConnection.h
+++ b/include/iocore/net/NetVConnection.h
@@ -541,7 +541,8 @@ protected:
   bool got_local_addr  = false;
   bool got_remote_addr = false;
 
-  bool is_internal_request  = false;
+  bool is_internal_request = false;
+  /// Indicate whether remapping will be done for this connection.
   bool is_unmanaged_request = false;
   /// Set if this connection is transparent.
   bool is_transparent = false;
diff --git a/include/proxy/http/Http1ClientSession.h 
b/include/proxy/http/Http1ClientSession.h
index ed8d79e9c6..dcf416c6a0 100644
--- a/include/proxy/http/Http1ClientSession.h
+++ b/include/proxy/http/Http1ClientSession.h
@@ -99,7 +99,9 @@ private:
     HCS_CLOSED,
   };
 
-  int  magic          = HTTP_CS_MAGIC_DEAD;
+  int magic = HTTP_CS_MAGIC_DEAD;
+
+  /// A monotonically increasing count of all transactions ever handled by the 
session.
   int  transact_count = 0;
   bool half_close     = false;
   bool conn_decrease  = false;
diff --git a/include/proxy/http/HttpSM.h b/include/proxy/http/HttpSM.h
index 5898a3a1f0..d0eda2fea2 100644
--- a/include/proxy/http/HttpSM.h
+++ b/include/proxy/http/HttpSM.h
@@ -366,7 +366,6 @@ private:
   int state_http_server_open(int event, void *data);
   int state_raw_http_server_open(int event, void *data);
   int state_send_server_request_header(int event, void *data);
-  int state_acquire_server_read(int event, void *data);
   int state_read_server_response_header(int event, void *data);
 
   // API
@@ -402,7 +401,7 @@ private:
   bool is_prewarm_enabled_or_sni_overridden(const TLSTunnelSupport &tts) const;
   void open_prewarmed_connection();
   void send_origin_throttled_response();
-  void do_setup_post_tunnel(HttpVC_t to_vc_type);
+  void do_setup_client_request_body_tunnel(HttpVC_t to_vc_type);
   void do_cache_prepare_write();
   void do_cache_prepare_write_transform();
   void do_cache_prepare_update();
@@ -507,7 +506,7 @@ public:
   bool    server_ssl_reused               = false;
   bool    server_connection_is_ssl        = false;
   bool    is_waiting_for_full_body        = false;
-  bool    is_using_post_buffer            = false;
+  bool    is_buffering_request_body       = false;
   // hooks_set records whether there are any hooks relevant
   //  to this transaction.  Used to avoid costly calls
   //  do_api_callout_internal()
diff --git a/src/proxy/http/Http1ClientSession.cc 
b/src/proxy/http/Http1ClientSession.cc
index fc947d6239..a3f66c0c42 100644
--- a/src/proxy/http/Http1ClientSession.cc
+++ b/src/proxy/http/Http1ClientSession.cc
@@ -406,7 +406,8 @@ Http1ClientSession::state_keep_alive(int event, void *data)
   return 0;
 }
 
-// Called from the Http1Transaction::release
+// Called from the Http1Transaction::release or at the start of a session for
+// the very first transaction from Http1ClientSession::new_connection.
 void
 Http1ClientSession::release(ProxyTransaction *trans)
 {
diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index dca99d1f82..1b9f32b530 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -2079,7 +2079,7 @@ HttpSM::state_send_server_request_header(int event, void 
*data)
         } else {
           // Go ahead and set up the post tunnel if we are not waiting for a 
100 response
           if (!t_state.hdr_info.client_request.m_100_continue_required) {
-            do_setup_post_tunnel(HTTP_SERVER_VC);
+            do_setup_client_request_body_tunnel(HTTP_SERVER_VC);
           }
         }
       }
@@ -2775,7 +2775,7 @@ HttpSM::tunnel_handler_post(int event, void *data)
     // It's time to start reading the response
     if (is_waiting_for_full_body) {
       is_waiting_for_full_body  = false;
-      is_using_post_buffer      = true;
+      is_buffering_request_body = true;
       client_request_body_bytes = this->postbuf_buffer_avail();
 
       call_transact_and_set_next_state(HttpTransact::HandleRequestBufferDone);
@@ -2932,7 +2932,7 @@ HttpSM::tunnel_handler_100_continue(int event, void *data)
       t_state.hdr_info.server_response.create(HTTP_TYPE_RESPONSE);
       handle_server_setup_error(VC_EVENT_EOS, server_entry->read_vio);
     } else {
-      do_setup_post_tunnel(HTTP_SERVER_VC);
+      do_setup_client_request_body_tunnel(HTTP_SERVER_VC);
     }
   } else {
     terminate_sm = true;
@@ -3826,13 +3826,13 @@ HttpSM::tunnel_handler_for_partial_post(int event, void 
* /* data ATS_UNUSED */)
   tunnel.reset();
 
   t_state.redirect_info.redirect_in_process = false;
-  is_using_post_buffer                      = false;
+  is_buffering_request_body                 = false;
 
   if (post_failed) {
     post_failed = false;
     handle_post_failure();
   } else {
-    do_setup_post_tunnel(HTTP_SERVER_VC);
+    do_setup_client_request_body_tunnel(HTTP_SERVER_VC);
   }
 
   return 0;
@@ -5981,7 +5981,8 @@ HttpSM::handle_http_server_open()
         server_txn->has_request_body(t_state.hdr_info.request_content_length,
                                      t_state.client_info.transfer_encoding == 
HttpTransact::CHUNKED_ENCODING) &&
         do_post_transform_open()) {
-      do_setup_post_tunnel(HTTP_TRANSFORM_VC); /* This doesn't seem quite 
right.  Should be sending the request header */
+      do_setup_client_request_body_tunnel(
+        HTTP_TRANSFORM_VC); /* This doesn't seem quite right.  Should be 
sending the request header */
     } else {
       setup_server_send_request_api();
     }
@@ -6186,7 +6187,7 @@ close_connection:
 }
 
 void
-HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
+HttpSM::do_setup_client_request_body_tunnel(HttpVC_t to_vc_type)
 {
   bool chunked = t_state.client_info.transfer_encoding == 
HttpTransact::CHUNKED_ENCODING ||
                  t_state.hdr_info.request_content_length == HTTP_UNDEFINED_CL;
@@ -6196,7 +6197,7 @@ HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
   // YTS Team, yamsat Plugin
   // if redirect_in_process and redirection is enabled add static producer
 
-  if (is_using_post_buffer ||
+  if (is_buffering_request_body ||
       (t_state.redirect_info.redirect_in_process && enable_redirection && 
this->_postbuf.postdata_copy_buffer_start != nullptr)) {
     post_redirect = true;
     // copy the post data into a new producer buffer for static producer
@@ -6238,7 +6239,7 @@ HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
                                                 chunked ? 
_ua.get_txn()->get_remote_reader()->read_avail() : post_bytes);
 
     // If is_using_post_buffer has been used, then client_request_body_bytes
-    // will have already been set in wait_for_full_body and there will be
+    // will have already been sent in wait_for_full_body and there will be
     // zero bytes in this user agent buffer. We don't want to clobber
     // client_request_body_bytes with a zero value here in those cases.
     if (client_request_body_bytes == 0) {
diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc
index f2a6308c21..4a3e93b1f2 100644
--- a/src/proxy/http/HttpTransact.cc
+++ b/src/proxy/http/HttpTransact.cc
@@ -1504,7 +1504,7 @@ HttpTransact::HandleRequest(State *s)
 {
   TxnDbg(dbg_ctl_http_trans, "START HttpTransact::HandleRequest");
 
-  if (!s->state_machine->is_waiting_for_full_body && 
!s->state_machine->is_using_post_buffer) {
+  if (!s->state_machine->is_waiting_for_full_body && 
!s->state_machine->is_buffering_request_body) {
     ink_assert(!s->hdr_info.server_request.valid());
 
     Metrics::Counter::increment(http_rsb.incoming_requests);

Reply via email to