Klaus Demo nginx / fae6878
Limit req: fixed delaying subrequests. Since limit_req uses connection's write event to delay request processing, it can conflict with timers in other subrequests. In particular, even if applied to an active subrequest, it can break things if wev->delayed is already set (due to limit_rate or sendfile_max_chunk), since after limit_req finishes the wev->delayed flag will be set and no timer will be active. Fix is to use the wev->delayed flag in limit_req as well. This ensures that wev->delayed won't be set after limit_req finishes, and also ensures that limit_req's timers will be properly handled by other subrequests if the one delayed by limit_req is not active. Maxim Dounin 3 years ago
1 changed file(s) with 4 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
275275
276276 r->read_event_handler = ngx_http_test_reading;
277277 r->write_event_handler = ngx_http_limit_req_delay;
278
279 r->connection->write->delayed = 1;
278280 ngx_add_timer(r->connection->write, delay);
279281
280282 return NGX_AGAIN;
291293
292294 wev = r->connection->write;
293295
294 if (!wev->timedout) {
296 if (wev->delayed && !wev->timedout) {
295297
296298 if (ngx_handle_write_event(wev, 0) != NGX_OK) {
297299 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
300302 return;
301303 }
302304
305 wev->delayed = 0;
303306 wev->timedout = 0;
304307
305308 if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) {