[PATCH 1 of 6] Core: recall write handler if subrequest changed

Maxim Dounin mdounin at mdounin.ru
Mon Oct 27 17:53:21 MSK 2008

# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1225108949 -10800
# Node ID 824321c85af87f85f9a3e56b0dd69d0a84c8d54f
# Parent  5410f1e19796ccfcc08cf3d1c996537328a4fb42
Core: recall write handler if subrequest changed.

If complex reply was buffered after postpone filter (e.g. in gzip filter
module), and this happened just after switching to next postponed subrequest,
the copy filter has no chance to reclaim freed buffers and send more data.

To resolve this, just post an additional write event in ngx_http_writer()
if we got NGX_AGAIN and subrequest has been changed.

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1981,6 +1981,11 @@ ngx_http_writer(ngx_http_request_t *r)
                    rc, &r->uri, &r->args);
     if (rc == NGX_AGAIN) {
+        if (r != c->data) {
+            ngx_post_event(wev, &ngx_posted_events);
+            return;
+        }
         clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module);
         if (!wev->ready && !wev->delayed) {
             ngx_add_timer(wev, clcf->send_timeout);

More information about the nginx mailing list