diff src/http/modules/perl/ngx_http_perl_module.c @ 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 eada22643e8b
children 903fb1ddc07f
line wrap: on
line diff
--- 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_req
 
     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);
 }