diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc index 4fbac851be8..1bfc10b2836 100644 --- a/proxy/http/HttpTunnel.cc +++ b/proxy/http/HttpTunnel.cc @@ -956,6 +956,9 @@ HttpTunnel::producer_run(HttpTunnelProducer *p) // Start the writes now that we know we will consume all the initial data c->write_vio = c->vc->do_io_write(this, c_write, c->buffer_reader); ink_assert(c_write > 0); + if (c->write_vio == nullptr) { + consumer_handler(VC_EVENT_ERROR, c); + } } } if (p->alive) { diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc index 1a72de1e739..d788f04340e 100644 --- a/proxy/http2/Http2Stream.cc +++ b/proxy/http2/Http2Stream.cc @@ -331,8 +331,12 @@ Http2Stream::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *abuffe write_vio.op = VIO::WRITE; response_reader = abuffer; - update_write_request(abuffer, nbytes, false); - + if (c != nullptr && nbytes > 0 && this->is_client_state_writeable()) { + update_write_request(abuffer, nbytes, false); + } else if (!this->is_client_state_writeable()) { + // Cannot start a write on a closed stream + return nullptr; + } return &write_vio; }