Perl: fixed delaying subrequests.

Much like in limit_req, use the wev->delayed flag to ensure proper handling
and interoperability with limit_rate.
This commit is contained in:
Maxim Dounin 2017-04-02 14:32:28 +03:00
parent 8a0dcc1b22
commit 5611ad024e
2 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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);
}