nghttpx: Don't keep backend connection if request buffer is not empty
This commit is contained in:
parent
5ff6da11b1
commit
8026bdd45a
|
@ -905,9 +905,12 @@ BlockedLink *Downstream::detach_blocked_link() {
|
|||
}
|
||||
|
||||
bool Downstream::can_detach_downstream_connection() const {
|
||||
// We should check request and response buffer. If request buffer
|
||||
// is not empty, then we might leave downstream connection in weird
|
||||
// state, especially for HTTP/1.1
|
||||
return dconn_ && response_state_ == Downstream::MSG_COMPLETE &&
|
||||
request_state_ == Downstream::MSG_COMPLETE && !upgraded_ &&
|
||||
!resp_.connection_close;
|
||||
!resp_.connection_close && request_buf_.rleft() == 0;
|
||||
}
|
||||
|
||||
DefaultMemchunks Downstream::pop_response_buf() {
|
||||
|
|
|
@ -628,14 +628,13 @@ int HttpsUpstream::on_write() {
|
|||
// We need to postpone detachment until all data are sent so that
|
||||
// we can notify nghttp2 library all data consumed.
|
||||
if (downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||
if (resp.connection_close ||
|
||||
downstream->get_request_state() != Downstream::MSG_COMPLETE) {
|
||||
if (downstream->can_detach_downstream_connection()) {
|
||||
// Keep-alive
|
||||
downstream->detach_downstream_connection();
|
||||
} else {
|
||||
// Connection close
|
||||
downstream->pop_downstream_connection();
|
||||
// dconn was deleted
|
||||
} else {
|
||||
// Keep-alive
|
||||
downstream->detach_downstream_connection();
|
||||
}
|
||||
// We need this if response ends before request.
|
||||
if (downstream->get_request_state() == Downstream::MSG_COMPLETE) {
|
||||
|
|
Loading…
Reference in New Issue