Mercurial > hg > nginx
changeset 6960:1c5e5e5b008d
Perl: fixed delaying subrequests.
Much like in limit_req, use the wev->delayed flag to ensure proper handling
and interoperability with limit_rate.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 02 Apr 2017 14:32:28 +0300 |
parents | 7fcf209d40c8 |
children | 903fb1ddc07f |
files | src/http/modules/perl/nginx.xs src/http/modules/perl/ngx_http_perl_module.c |
diffstat | 2 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/perl/nginx.xs Sun Apr 02 14:32:26 2017 +0300 +++ b/src/http/modules/perl/nginx.xs Sun Apr 02 14:32:28 2017 +0300 @@ -1001,6 +1001,7 @@ ctx->next = SvRV(ST(2)); + r->connection->write->delayed = 1; ngx_add_timer(r->connection->write, sleep); r->write_event_handler = ngx_http_perl_sleep_handler;
--- a/src/http/modules/perl/ngx_http_perl_module.c Sun Apr 02 14:32:26 2017 +0300 +++ b/src/http/modules/perl/ngx_http_perl_module.c Sun Apr 02 14:32:28 2017 +0300 @@ -278,15 +278,19 @@ wev = r->connection->write; - if (wev->timedout) { - wev->timedout = 0; - ngx_http_perl_handle_request(r); + if (wev->delayed && !wev->timedout) { + + if (ngx_handle_write_event(wev, 0) != NGX_OK) { + ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + } + return; } - if (ngx_handle_write_event(wev, 0) != NGX_OK) { - ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); - } + wev->delayed = 0; + wev->timedout = 0; + + ngx_http_perl_handle_request(r); }