nghttpx: Don't fail backend connection if one of backend request fails
This commit is contained in:
parent
31d99b3664
commit
ca87b45fe4
|
@ -1291,9 +1291,23 @@ int Http2Session::on_connect()
|
|||
|
||||
// submit pending request
|
||||
for(auto dconn : dconns_) {
|
||||
if(dconn->push_request_headers() != 0) {
|
||||
return -1;
|
||||
if(dconn->push_request_headers() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(LOG_ENABLED(INFO)) {
|
||||
SSLOG(INFO, this) << "backend request failed";
|
||||
}
|
||||
|
||||
auto downstream = dconn->get_downstream();
|
||||
|
||||
if(!downstream) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto upstream = downstream->get_upstream();
|
||||
|
||||
upstream->on_downstream_abort_request(downstream, 400);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1216,4 +1216,18 @@ int Http2Upstream::resume_read(IOCtrlReason reason, Downstream *downstream)
|
|||
return send();
|
||||
}
|
||||
|
||||
int Http2Upstream::on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = error_reply(downstream, status_code);
|
||||
|
||||
if(rv != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return send();
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
virtual int on_read();
|
||||
virtual int on_write();
|
||||
virtual int on_event();
|
||||
virtual int on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code);
|
||||
int send();
|
||||
virtual ClientHandler* get_client_handler() const;
|
||||
virtual bufferevent_data_cb get_downstream_readcb();
|
||||
|
|
|
@ -887,4 +887,10 @@ int HttpsUpstream::on_downstream_body_complete(Downstream *downstream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int HttpsUpstream::on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code)
|
||||
{
|
||||
return error_reply(status_code);
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -44,7 +44,8 @@ public:
|
|||
virtual int on_read();
|
||||
virtual int on_write();
|
||||
virtual int on_event();
|
||||
//int send();
|
||||
virtual int on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code);
|
||||
virtual ClientHandler* get_client_handler() const;
|
||||
virtual bufferevent_data_cb get_downstream_readcb();
|
||||
virtual bufferevent_data_cb get_downstream_writecb();
|
||||
|
|
|
@ -1030,4 +1030,18 @@ int SpdyUpstream::resume_read(IOCtrlReason reason, Downstream *downstream)
|
|||
return send();
|
||||
}
|
||||
|
||||
int SpdyUpstream::on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = error_reply(downstream, status_code);
|
||||
|
||||
if(rv != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return send();
|
||||
}
|
||||
|
||||
} // namespace shrpx
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
virtual int on_read();
|
||||
virtual int on_write();
|
||||
virtual int on_event();
|
||||
virtual int on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code);
|
||||
int send();
|
||||
virtual ClientHandler* get_client_handler() const;
|
||||
virtual bufferevent_data_cb get_downstream_readcb();
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
virtual int on_read() = 0;
|
||||
virtual int on_write() = 0;
|
||||
virtual int on_event() = 0;
|
||||
virtual int on_downstream_abort_request(Downstream *downstream,
|
||||
unsigned int status_code) = 0;
|
||||
virtual bufferevent_data_cb get_downstream_readcb() = 0;
|
||||
virtual bufferevent_data_cb get_downstream_writecb() = 0;
|
||||
virtual bufferevent_event_cb get_downstream_eventcb() = 0;
|
||||
|
|
Loading…
Reference in New Issue