From f1049a66e2cd59a022be95cfe9f29537e95ab144 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 31 Jan 2015 01:11:55 +0900 Subject: [PATCH] nghttpx: Detach DownstreamConnection early --- src/shrpx_http2_upstream.cc | 7 +++++++ src/shrpx_https_upstream.cc | 8 ++++++++ src/shrpx_spdy_upstream.cc | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index bf586a3d..f2b47bf3 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -898,6 +898,13 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) { } return downstream_error(dconn, Downstream::EVENT_ERROR); } + // Detach downstream connection early so that it could be reused + // without hitting server's request timeout. + if (downstream->get_response_state() == Downstream::MSG_COMPLETE && + !downstream->get_response_connection_close()) { + // Keep-alive + downstream->detach_downstream_connection(); + } } handler_->signal_write(); diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 701b2ab3..0198a737 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -465,6 +465,14 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) { goto end; } + // Detach downstream connection early so that it could be reused + // without hitting server's request timeout. + if (downstream->get_response_state() == Downstream::MSG_COMPLETE && + !downstream->get_response_connection_close()) { + // Keep-alive + downstream->detach_downstream_connection(); + } + if (rv == DownstreamConnection::ERR_EOF) { return downstream_eof(dconn); } diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 06b8414d..09cddf4c 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -552,6 +552,13 @@ int SpdyUpstream::downstream_read(DownstreamConnection *dconn) { } return downstream_error(dconn, Downstream::EVENT_ERROR); } + // Detach downstream connection early so that it could be reused + // without hitting server's request timeout. + if (downstream->get_response_state() == Downstream::MSG_COMPLETE && + !downstream->get_response_connection_close()) { + // Keep-alive + downstream->detach_downstream_connection(); + } } handler_->signal_write();