diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc index 1e5601dd6ee..df95e1f4ccf 100644 --- a/proxy/http/Http1ClientSession.cc +++ b/proxy/http/Http1ClientSession.cc @@ -253,6 +253,10 @@ Http1ClientSession::do_io_close(int alerrno) if (transact_count == released_transactions) { half_close = false; } + + // Clean up the write VIO in case of inactivity timeout + this->do_io_write(nullptr, 0, nullptr); + if (half_close && this->trans.get_sm()) { read_state = HCS_HALF_CLOSED; SET_HANDLER(&Http1ClientSession::state_wait_for_close); @@ -286,7 +290,6 @@ Http1ClientSession::do_io_close(int alerrno) HTTP_SUM_DYN_STAT(http_transactions_per_client_con, transact_count); HTTP_DECREMENT_DYN_STAT(http_current_client_connections_stat); conn_decrease = false; - // the netvc will be closed in the session free } if (transact_count == released_transactions) { this->destroy(); @@ -313,6 +316,10 @@ Http1ClientSession::state_wait_for_close(int event, void *data) case VC_EVENT_INACTIVITY_TIMEOUT: half_close = false; this->do_io_close(); + if (client_vc != nullptr) { + client_vc->do_io_close(); + client_vc = nullptr; + } break; case VC_EVENT_READ_READY: // Drain any data read @@ -389,6 +396,10 @@ Http1ClientSession::state_keep_alive(int event, void *data) case VC_EVENT_EOS: this->do_io_close(); + if (client_vc != nullptr) { + client_vc->do_io_close(); + client_vc = nullptr; + } break; case VC_EVENT_READ_COMPLETE: diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc index 9885557e40f..ca37b8af79c 100644 --- a/proxy/http2/Http2ClientSession.cc +++ b/proxy/http2/Http2ClientSession.cc @@ -300,14 +300,15 @@ Http2ClientSession::do_io_close(int alerrno) ink_assert(this->mutex->thread_holding == this_ethread()); send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_FINI, this); - // client_vc will be closed in Http2ClientSession::free - { SCOPED_MUTEX_LOCK(lock, this->connection_state.mutex, this_ethread()); this->connection_state.release_stream(); } this->clear_session_active(); + + // Clean up the write VIO in case of inactivity timeout + this->do_io_write(nullptr, 0, nullptr); } void @@ -375,6 +376,10 @@ Http2ClientSession::main_event_handler(int event, void *edata) case VC_EVENT_EOS: this->set_dying_event(event); this->do_io_close(); + if (client_vc != nullptr) { + client_vc->do_io_close(); + client_vc = nullptr; + } retval = 0; break;