shrpx: Check return value of HttpsUpstream::resume_read()
Currently, resume_read() fails if on_read() returns -1 in case that evbuffer_add failed, which means, most likely, memory allocation failure. ClientHandler is marked "should be closed", but if evbuffer_add is failed, write callback will not be invoked and its marking is not evaluated. It will eventually be deleted when the client is disconnected or backend failure though.
This commit is contained in:
parent
99b687ceca
commit
4876412f7d
|
@ -399,7 +399,9 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
|
|||
} else {
|
||||
upstream->delete_downstream();
|
||||
// Process next HTTP request
|
||||
upstream->resume_read(SHRPX_MSG_BLOCK, 0);
|
||||
if(upstream->resume_read(SHRPX_MSG_BLOCK, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -425,7 +427,9 @@ void https_downstream_readcb(bufferevent *bev, void *ptr)
|
|||
if(downstream->get_request_state() == Downstream::MSG_COMPLETE) {
|
||||
upstream->delete_downstream();
|
||||
// Process next HTTP request
|
||||
upstream->resume_read(SHRPX_MSG_BLOCK, 0);
|
||||
if(upstream->resume_read(SHRPX_MSG_BLOCK, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -442,6 +446,7 @@ void https_downstream_writecb(bufferevent *bev, void *ptr)
|
|||
Downstream *downstream = dconn->get_downstream();
|
||||
HttpsUpstream *upstream;
|
||||
upstream = static_cast<HttpsUpstream*>(downstream->get_upstream());
|
||||
// May return -1
|
||||
upstream->resume_read(SHRPX_NO_BUFFER, downstream);
|
||||
}
|
||||
} // namespace
|
||||
|
@ -493,7 +498,9 @@ void https_downstream_eventcb(bufferevent *bev, short events, void *ptr)
|
|||
}
|
||||
if(downstream->get_request_state() == Downstream::MSG_COMPLETE) {
|
||||
upstream->delete_downstream();
|
||||
upstream->resume_read(SHRPX_MSG_BLOCK, 0);
|
||||
if(upstream->resume_read(SHRPX_MSG_BLOCK, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if(events & (BEV_EVENT_ERROR | BEV_EVENT_TIMEOUT)) {
|
||||
if(LOG_ENABLED(INFO)) {
|
||||
|
@ -517,7 +524,9 @@ void https_downstream_eventcb(bufferevent *bev, short events, void *ptr)
|
|||
}
|
||||
if(downstream->get_request_state() == Downstream::MSG_COMPLETE) {
|
||||
upstream->delete_downstream();
|
||||
upstream->resume_read(SHRPX_MSG_BLOCK, 0);
|
||||
if(upstream->resume_read(SHRPX_MSG_BLOCK, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue