summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2017-04-02 14:32:28 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2017-04-02 14:32:28 +0300
commit96e4e84ce273664d0ee43c5c5b7d14efa6f86d39 (patch)
treeced1313613d1fbfe5036106c62a0e5377f6175c8
parentfae6878f202b13f0ffe39f75fe19fa15e179e9d5 (diff)
Perl: fixed delaying subrequests.
Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
-rw-r--r--src/http/modules/perl/nginx.xs1
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c16
2 files changed, 11 insertions, 6 deletions
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
index 6716620af..cca64da37 100644
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -1001,6 +1001,7 @@ sleep(r, sleep, next)
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;
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 279631974..79ded0f2f 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -278,15 +278,19 @@ ngx_http_perl_sleep_handler(ngx_http_request_t *r)
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);
}