From 99dc31ff1a6ed5038dc41e15452e35937bd5f294 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 30 Aug 2016 23:37:49 +0900 Subject: [PATCH] nghttpx: Retry if backend h1 connection cannot be established due to timeout --- src/shrpx_http_downstream_connection.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index feb548f3..65e2cb37 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -80,12 +80,19 @@ void connect_timeoutcb(struct ev_loop *loop, ev_timer *w, int revents) { auto downstream = dconn->get_downstream(); auto upstream = downstream->get_upstream(); auto handler = upstream->get_client_handler(); - auto &resp = downstream->response(); - // Do this so that dconn is not pooled - resp.connection_close = true; + downstream->pop_downstream_connection(); - if (upstream->downstream_error(dconn, Downstream::EVENT_TIMEOUT) != 0) { + auto ndconn = handler->get_downstream_connection(downstream); + if (ndconn) { + if (downstream->attach_downstream_connection(std::move(ndconn)) == 0) { + return; + } + } + + downstream->set_request_state(Downstream::CONNECT_FAIL); + + if (upstream->on_downstream_abort_request(downstream, 504) != 0) { delete handler; } }