]> git.kaiwu.me - nginx.git/commitdiff
Write filter: replaced unneeded loop with one to free chains.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 5 Sep 2012 15:06:47 +0000 (15:06 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 5 Sep 2012 15:06:47 +0000 (15:06 +0000)
Noted by Gabor Lekeny.

src/http/ngx_http_write_filter_module.c

index 72b1f9b2fd7f8ccc9ccfd6fa0be9ea930dd8b1de..fd44bc65948c41a349a1cfbc682180a40c964984 100644 (file)
@@ -185,18 +185,14 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
     }
 
     if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) {
-        if (last) {
-            r->out = NULL;
-            c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
-
-            return NGX_OK;
-        }
-
-        if (flush) {
-            do {
-                r->out = r->out->next;
-            } while (r->out);
+        if (last || flush) {
+            for (cl = r->out; cl; /* void */) {
+                ln = cl;
+                cl = cl->next;
+                ngx_free_chain(r->pool, ln);
+            }
 
+            r->out = NULL;
             c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
 
             return NGX_OK;