You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2021/04/12 00:42:08 UTC

[trafficserver] branch 8.1.x updated: Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641) (#7698)

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

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


The following commit(s) were added to refs/heads/8.1.x by this push:
     new 4e11206  Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641) (#7698)
4e11206 is described below

commit 4e11206fac7ba683c9ac7b44e8b69181008147e0
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Mon Apr 12 09:41:51 2021 +0900

    Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641) (#7698)
    
    * Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641)
    
    (cherry picked from commit 270ca6e84eba758e44c9b2a15046eaa7b8af8d8a)
    
    * Fix has_consumer_besides_client to deal with no clients (#7685)
    
    (cherry picked from commit 09e72839258a4f748aace4908c996e843e6d5176)
    
    Co-authored-by: Susan Hinrichs <sh...@verizonmedia.com>
---
 proxy/http/HttpSM.cc    |  4 ++--
 proxy/http/HttpTunnel.h | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index e43fd32..f222714 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -839,9 +839,9 @@ HttpSM::state_watch_for_client_abort(int event, void *data)
    * client.
    */
   case VC_EVENT_EOS: {
-    // We got an early EOS.
+    // We got an early EOS. If the tunnal has cache writer, don't kill it for background fill.
     NetVConnection *netvc = ua_txn->get_netvc();
-    if (ua_txn->allow_half_open()) {
+    if (ua_txn->allow_half_open() || tunnel.has_consumer_besides_client()) {
       if (netvc) {
         netvc->do_io_shutdown(IO_SHUTDOWN_READ);
       }
diff --git a/proxy/http/HttpTunnel.h b/proxy/http/HttpTunnel.h
index a432f3f..9cc5155 100644
--- a/proxy/http/HttpTunnel.h
+++ b/proxy/http/HttpTunnel.h
@@ -282,6 +282,7 @@ public:
   }
   bool is_tunnel_alive() const;
   bool has_cache_writer() const;
+  bool has_consumer_besides_client() const;
 
   HttpTunnelProducer *add_producer(VConnection *vc, int64_t nbytes, IOBufferReader *reader_start, HttpProducerHandler sm_handler,
                                    HttpTunnelType_t vc_type, const char *name);
@@ -514,6 +515,31 @@ HttpTunnel::has_cache_writer() const
   return false;
 }
 
+/**
+   Return false if there is only a consumer for client
+ */
+inline bool
+HttpTunnel::has_consumer_besides_client() const
+{
+  bool res = false; // case of no consumers
+
+  for (const auto &consumer : consumers) {
+    if (!consumer.alive) {
+      continue;
+    }
+
+    if (consumer.vc_type == HT_HTTP_CLIENT) {
+      res = false;
+      continue;
+    } else {
+      res = true;
+      break;
+    }
+  }
+
+  return res;
+}
+
 inline bool
 HttpTunnelConsumer::is_downstream_from(VConnection *vc)
 {