diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 37d1a63ef51..a9df35b60da 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -973,9 +973,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 ab00edda971..3d80d2b1540 100644 --- a/proxy/http/HttpTunnel.h +++ b/proxy/http/HttpTunnel.h @@ -281,6 +281,7 @@ class HttpTunnel : public Continuation } 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); @@ -513,6 +514,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) {