Write filter: replaced unneeded loop with one to free chains.
Noted by Gabor Lekeny.
diff --git a/src/http/ngx_http_write_filter_module.c b/src/http/ngx_http_write_filter_module.c
index 72b1f9b..fd44bc6 100644
--- a/src/http/ngx_http_write_filter_module.c
+++ b/src/http/ngx_http_write_filter_module.c
@@ -185,23 +185,19 @@
}
if (size == 0 && !(c->buffered & NGX_LOWLEVEL_BUFFERED)) {
- if (last) {
+ 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;
}
- if (flush) {
- do {
- r->out = r->out->next;
- } while (r->out);
-
- c->buffered &= ~NGX_HTTP_WRITE_BUFFERED;
-
- return NGX_OK;
- }
-
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
"the http output chain is empty");