When client or upstream connection is closed, level-triggered read event
remained active until the end of the session leading to cpu hog. Now the flag
NGX_CLOSE_EVENT is used to unschedule the event.
size_t size;
ssize_t n;
ngx_buf_t *b;
+ ngx_uint_t flags;
ngx_connection_t *c, *pc, *src, *dst;
ngx_log_handler_pt handler;
ngx_stream_upstream_t *u;
return NGX_DONE;
}
- if (ngx_handle_read_event(src->read, 0) != NGX_OK) {
+ flags = src->read->eof ? NGX_CLOSE_EVENT : 0;
+
+ if (ngx_handle_read_event(src->read, flags) != NGX_OK) {
ngx_stream_proxy_finalize(s, NGX_ERROR);
return NGX_ERROR;
}