Skip to content

Commit 31c3884

Browse files
masaori335zwoop
authored andcommitted
Do NOT kill tunnel if it has any consumer besides HT_HTTP_CLIENT (#7641)
(cherry picked from commit 270ca6e)
1 parent dbfe581 commit 31c3884

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

proxy/http/HttpSM.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,9 @@ HttpSM::state_watch_for_client_abort(int event, void *data)
981981
* client.
982982
*/
983983
case VC_EVENT_EOS: {
984-
// We got an early EOS.
984+
// We got an early EOS. If the tunnal has cache writer, don't kill it for background fill.
985985
NetVConnection *netvc = ua_txn->get_netvc();
986-
if (ua_txn->allow_half_open()) {
986+
if (ua_txn->allow_half_open() || tunnel.has_consumer_besides_client()) {
987987
if (netvc) {
988988
netvc->do_io_shutdown(IO_SHUTDOWN_READ);
989989
}

proxy/http/HttpTunnel.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class HttpTunnel : public Continuation
282282
}
283283
bool is_tunnel_alive() const;
284284
bool has_cache_writer() const;
285+
bool has_consumer_besides_client() const;
285286

286287
HttpTunnelProducer *add_producer(VConnection *vc, int64_t nbytes, IOBufferReader *reader_start, HttpProducerHandler sm_handler,
287288
HttpTunnelType_t vc_type, const char *name);
@@ -514,6 +515,31 @@ HttpTunnel::has_cache_writer() const
514515
return false;
515516
}
516517

518+
/**
519+
Return false if there is only a consumer for client
520+
*/
521+
inline bool
522+
HttpTunnel::has_consumer_besides_client() const
523+
{
524+
bool res = true;
525+
526+
for (const auto &consumer : consumers) {
527+
if (!consumer.alive) {
528+
continue;
529+
}
530+
531+
if (consumer.vc_type == HT_HTTP_CLIENT) {
532+
res = false;
533+
continue;
534+
} else {
535+
res = true;
536+
break;
537+
}
538+
}
539+
540+
return res;
541+
}
542+
517543
inline bool
518544
HttpTunnelConsumer::is_downstream_from(VConnection *vc)
519545
{

0 commit comments

Comments
 (0)