mirror of https://github.com/grpc/grpc-web.git
Always invoke ngx_handle_write_event() after ngx_http_output_filter(),
in spite of its return value. This is required to support select/poll besides epoll. Also close the downstream connection when ngx_handle_write_event() failing.
This commit is contained in:
parent
1f7f80b33e
commit
8b88ff2f84
|
|
@ -94,10 +94,12 @@ void continue_read_request_body(ngx_http_request_t *r) {
|
|||
void continue_write_response(ngx_http_request_t *r) {
|
||||
if (ngx_http_output_filter(r, nullptr) == NGX_AGAIN) {
|
||||
r->write_event_handler = continue_write_response;
|
||||
ngx_handle_write_event(r->connection->write, 0);
|
||||
} else {
|
||||
r->write_event_handler = ngx_http_request_empty_handler;
|
||||
}
|
||||
if (ngx_handle_write_event(r->connection->write, 0) != NGX_OK) {
|
||||
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
void client_liveness_detection_handler(ngx_event_t *event) {
|
||||
|
|
@ -271,7 +273,11 @@ void NginxHttpFrontend::SendResponseMessageToClient(Response *response) {
|
|||
ngx_chain_seek_to_last(output)->buf->flush = 1;
|
||||
if (ngx_http_output_filter(http_request_, output) == NGX_AGAIN) {
|
||||
http_request_->write_event_handler = continue_write_response;
|
||||
ngx_handle_write_event(http_request_->connection->write, 0);
|
||||
}
|
||||
if (ngx_handle_write_event(http_request_->connection->write, 0) !=
|
||||
NGX_OK) {
|
||||
ngx_http_finalize_request(http_request_,
|
||||
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -587,7 +593,9 @@ void NginxHttpFrontend::WriteToNginxResponse(uint8_t *data, size_t size) {
|
|||
ngx_chain_seek_to_last(output)->buf->flush = 1;
|
||||
if (ngx_http_output_filter(http_request_, output) == NGX_AGAIN) {
|
||||
http_request_->write_event_handler = continue_write_response;
|
||||
ngx_handle_write_event(http_request_->connection->write, 0);
|
||||
}
|
||||
if (ngx_handle_write_event(http_request_->connection->write, 0) != NGX_OK) {
|
||||
ngx_http_finalize_request(http_request_, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
} // namespace gateway
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue