nghttpx: Reconnect h1 backend if it lost connection before sending headers
This is the second attempt. The first attempt was
8a59ce6d37
and it failed.
This commit is contained in:
parent
89c33d690f
commit
f8933fe504
|
@ -1262,8 +1262,11 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) {
|
|||
} else {
|
||||
auto rv = downstream->on_read();
|
||||
if (rv == SHRPX_ERR_EOF) {
|
||||
if (downstream->get_request_header_sent()) {
|
||||
return downstream_eof(dconn);
|
||||
}
|
||||
return SHRPX_ERR_RETRY;
|
||||
}
|
||||
if (rv == SHRPX_ERR_DCONN_CANCELED) {
|
||||
downstream->pop_downstream_connection();
|
||||
handler_->signal_write();
|
||||
|
|
|
@ -138,26 +138,33 @@ void connect_timeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void backend_retry(Downstream *downstream) {
|
||||
retry_downstream_connection(downstream, 502);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void readcb(struct ev_loop *loop, ev_io *w, int revents) {
|
||||
int rv;
|
||||
auto conn = static_cast<Connection *>(w->data);
|
||||
auto dconn = static_cast<HttpDownstreamConnection *>(conn->data);
|
||||
auto downstream = dconn->get_downstream();
|
||||
auto upstream = downstream->get_upstream();
|
||||
auto handler = upstream->get_client_handler();
|
||||
|
||||
if (upstream->downstream_read(dconn) != 0) {
|
||||
rv = upstream->downstream_read(dconn);
|
||||
if (rv != 0) {
|
||||
if (rv == SHRPX_ERR_RETRY) {
|
||||
backend_retry(downstream);
|
||||
return;
|
||||
}
|
||||
|
||||
delete handler;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void backend_retry(Downstream *downstream) {
|
||||
retry_downstream_connection(downstream, 502);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
void writecb(struct ev_loop *loop, ev_io *w, int revents) {
|
||||
int rv;
|
||||
|
|
|
@ -788,8 +788,11 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) {
|
|||
rv = downstream->on_read();
|
||||
|
||||
if (rv == SHRPX_ERR_EOF) {
|
||||
if (downstream->get_request_header_sent()) {
|
||||
return downstream_eof(dconn);
|
||||
}
|
||||
return SHRPX_ERR_RETRY;
|
||||
}
|
||||
|
||||
if (rv == SHRPX_ERR_DCONN_CANCELED) {
|
||||
downstream->pop_downstream_connection();
|
||||
|
|
Loading…
Reference in New Issue