# HG changeset patch # User Maxim Dounin # Date 1496071738 -10800 # Node ID aee676aa6c1fd39cc10b7e8b7ec04c8364ab0fa8 # Parent 3cdd7ed8681969780159cd74e56a2d09b03a4216 Fixed delaying subrequests. Similar to 7fcf209d40c8 in the limit_req module, we now set wev->delayed to avoid interference with other subrequests. With 903fb1ddc07f in nginx (wev->delayed handling moved to the connection event handler, nginx 1.11.13), it will be also possible to remove wev->timedout tests and wev->timedout / wev->delayed reset after the timer expiration. These are preserved for now to make the code compatible with older nginx versions. diff --git a/ngx_http_delay_module.c b/ngx_http_delay_module.c --- a/ngx_http_delay_module.c +++ b/ngx_http_delay_module.c @@ -92,6 +92,7 @@ ngx_http_delay_handler(ngx_http_request_ r->read_event_handler = ngx_http_test_reading; r->write_event_handler = ngx_http_delay_event_handler; + r->connection->write->delayed = 1; ngx_add_timer(r->connection->write, dcf->delay); ngx_http_set_ctx(r, (void *) 1, ngx_http_delay_module); @@ -110,7 +111,7 @@ ngx_http_delay_event_handler(ngx_http_re wev = r->connection->write; - if (!wev->timedout) { + if (wev->delayed && !wev->timedout) { if (ngx_handle_write_event(wev, 0) != NGX_OK) { ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -119,6 +120,7 @@ ngx_http_delay_event_handler(ngx_http_re return; } + wev->delayed = 0; wev->timedout = 0; if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) {