nghttpx: Detach DownstreamConnection early

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-31 01:11:55 +09:00
parent 5a497b9f30
commit f1049a66e2
3 changed files with 22 additions and 0 deletions

View File

@ -898,6 +898,13 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) {
} }
return downstream_error(dconn, Downstream::EVENT_ERROR); 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(); handler_->signal_write();

View File

@ -465,6 +465,14 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) {
goto end; 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) { if (rv == DownstreamConnection::ERR_EOF) {
return downstream_eof(dconn); return downstream_eof(dconn);
} }

View File

@ -552,6 +552,13 @@ int SpdyUpstream::downstream_read(DownstreamConnection *dconn) {
} }
return downstream_error(dconn, Downstream::EVENT_ERROR); 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(); handler_->signal_write();