This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 0ceccad534b34af1694627689725541268ef304f Author: Masaori Koshiba <[email protected]> AuthorDate: Fri Apr 2 07:56:13 2021 +0900 Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641) (cherry picked from commit 270ca6e84eba758e44c9b2a15046eaa7b8af8d8a) --- 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 aa88ede..1fa9ef7 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -901,9 +901,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 c6aa9fc..7774e2c 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 = true; + + 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) {
