nghttpx: Response with 503 when re-submission to backend failed

This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-20 19:23:52 +09:00
parent 6657966334
commit 50c4aa061f
3 changed files with 30 additions and 18 deletions

View File

@ -1420,10 +1420,7 @@ int Http2Upstream::on_downstream_reset(bool no_retry) {
downstream->add_retry(); downstream->add_retry();
if (no_retry || downstream->no_more_retry()) { if (no_retry || downstream->no_more_retry()) {
if (on_downstream_abort_request(downstream, 503) != 0) { goto fail;
return -1;
}
continue;
} }
// downstream connection is clean; we can retry with new // downstream connection is clean; we can retry with new
@ -1432,10 +1429,16 @@ int Http2Upstream::on_downstream_reset(bool no_retry) {
rv = downstream->attach_downstream_connection( rv = downstream->attach_downstream_connection(
handler_->get_downstream_connection()); handler_->get_downstream_connection());
if (rv != 0) { if (rv != 0) {
rst_stream(downstream, NGHTTP2_INTERNAL_ERROR); goto fail;
downstream->pop_downstream_connection();
continue;
} }
continue;
fail:
if (on_downstream_abort_request(downstream, 503) != 0) {
return -1;
}
downstream->pop_downstream_connection();
} }
handler_->signal_write(); handler_->signal_write();

View File

@ -854,17 +854,23 @@ int HttpsUpstream::on_downstream_reset(bool no_retry) {
downstream_->add_retry(); downstream_->add_retry();
if (no_retry || downstream_->no_more_retry()) { if (no_retry || downstream_->no_more_retry()) {
if (on_downstream_abort_request(downstream_.get(), 503) != 0) { goto fail;
return -1;
}
return 0;
} }
rv = downstream_->attach_downstream_connection( rv = downstream_->attach_downstream_connection(
handler_->get_downstream_connection()); handler_->get_downstream_connection());
if (rv != 0) { if (rv != 0) {
goto fail;
}
return 0;
fail:
if (on_downstream_abort_request(downstream_.get(), 503) != 0) {
return -1; return -1;
} }
downstream_->pop_downstream_connection();
return 0; return 0;
} }

View File

@ -1052,10 +1052,7 @@ int SpdyUpstream::on_downstream_reset(bool no_retry) {
downstream->add_retry(); downstream->add_retry();
if (no_retry || downstream->no_more_retry()) { if (no_retry || downstream->no_more_retry()) {
if (on_downstream_abort_request(downstream, 503) != 0) { goto fail;
return -1;
}
return 0;
} }
// downstream connection is clean; we can retry with new // downstream connection is clean; we can retry with new
@ -1064,10 +1061,16 @@ int SpdyUpstream::on_downstream_reset(bool no_retry) {
rv = downstream->attach_downstream_connection( rv = downstream->attach_downstream_connection(
handler_->get_downstream_connection()); handler_->get_downstream_connection());
if (rv != 0) { if (rv != 0) {
rst_stream(downstream, SPDYLAY_INTERNAL_ERROR); goto fail;
downstream->pop_downstream_connection();
continue;
} }
continue;
fail:
if (on_downstream_abort_request(downstream, 503) != 0) {
return -1;
}
downstream->pop_downstream_connection();
} }
handler_->signal_write(); handler_->signal_write();