mirror of
https://gitee.com/openharmony/third_party_nghttp2
synced 2024-11-24 00:10:12 +00:00
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,7 +1262,10 @@ int Http2Upstream::downstream_read(DownstreamConnection *dconn) {
|
||||
} else {
|
||||
auto rv = downstream->on_read();
|
||||
if (rv == SHRPX_ERR_EOF) {
|
||||
return downstream_eof(dconn);
|
||||
if (downstream->get_request_header_sent()) {
|
||||
return downstream_eof(dconn);
|
||||
}
|
||||
return SHRPX_ERR_RETRY;
|
||||
}
|
||||
if (rv == SHRPX_ERR_DCONN_CANCELED) {
|
||||
downstream->pop_downstream_connection();
|
||||
|
@ -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,7 +788,10 @@ int HttpsUpstream::downstream_read(DownstreamConnection *dconn) {
|
||||
rv = downstream->on_read();
|
||||
|
||||
if (rv == SHRPX_ERR_EOF) {
|
||||
return downstream_eof(dconn);
|
||||
if (downstream->get_request_header_sent()) {
|
||||
return downstream_eof(dconn);
|
||||
}
|
||||
return SHRPX_ERR_RETRY;
|
||||
}
|
||||
|
||||
if (rv == SHRPX_ERR_DCONN_CANCELED) {
|
||||
|
Loading…
Reference in New Issue
Block a user