aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2015-03-23 21:09:05 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2015-03-23 21:09:05 +0300
commit4df7aa6f92e6c6f70002f72caaef6eb0ba6aea82 (patch)
tree41bf54f068fe68b2d080f6720026291931280800
parent9131eb11c9b204cb12991013f84ffe0bfa64ac14 (diff)
downloadnginx-4df7aa6f92e6c6f70002f72caaef6eb0ba6aea82.tar.gz
nginx-4df7aa6f92e6c6f70002f72caaef6eb0ba6aea82.zip
Output chain: free chain links in ngx_chain_writer().
-rw-r--r--src/core/ngx_output_chain.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 5260c5f66..252359af6 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -654,7 +654,7 @@ ngx_chain_writer(void *data, ngx_chain_t *in)
ngx_chain_writer_ctx_t *ctx = data;
off_t size;
- ngx_chain_t *cl;
+ ngx_chain_t *cl, *ln, *chain;
ngx_connection_t *c;
c = ctx->connection;
@@ -734,15 +734,23 @@ ngx_chain_writer(void *data, ngx_chain_t *in)
return NGX_OK;
}
- ctx->out = c->send_chain(c, ctx->out, ctx->limit);
+ chain = c->send_chain(c, ctx->out, ctx->limit);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
- "chain writer out: %p", ctx->out);
+ "chain writer out: %p", chain);
- if (ctx->out == NGX_CHAIN_ERROR) {
+ if (chain == NGX_CHAIN_ERROR) {
return NGX_ERROR;
}
+ for (cl = ctx->out; cl && cl != chain; /* void */) {
+ ln = cl;
+ cl = cl->next;
+ ngx_free_chain(ctx->pool, ln);
+ }
+
+ ctx->out = chain;
+
if (ctx->out == NULL) {
ctx->last = &ctx->out;