Skip to content

Commit

Permalink
nghttpx: Retry if backend h1 connection cannot be established due to …
Browse files Browse the repository at this point in the history
…timeout
  • Loading branch information
tatsuhiro-t committed Aug 30, 2016
1 parent 7673848 commit 99dc31f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/shrpx_http_downstream_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 99dc31f

Please sign in to comment.