summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_output_chain.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2024-05-23 19:15:38 +0400
committerRoman Arutyunyan <arut@nginx.com>2024-05-23 19:15:38 +0400
commit75e3004902586f4120ddac4e3e00802a9024b79e (patch)
tree24526e9b535347cc344135357c8f4a0837dfb311 /src/core/ngx_output_chain.c
parenta728869cd10924b991b22c5b50a9317226499271 (diff)
downloadnginx-75e3004902586f4120ddac4e3e00802a9024b79e.tar.gz
nginx-75e3004902586f4120ddac4e3e00802a9024b79e.tar.bz2
Optimized chain link usage (ticket #2614).
Previously chain links could sometimes be dropped instead of being reused, which could result in increased memory consumption during long requests. A similar chain link issue in ngx_http_gzip_filter_module was fixed in da46bfc484ef (1.11.10). Based on a patch by Sangmin Lee.
Diffstat (limited to 'src/core/ngx_output_chain.c')
-rw-r--r--src/core/ngx_output_chain.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 857074253..a46209c17 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -117,7 +117,10 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
ngx_debug_point();
- ctx->in = ctx->in->next;
+ cl = ctx->in;
+ ctx->in = cl->next;
+
+ ngx_free_chain(ctx->pool, cl);
continue;
}
@@ -203,7 +206,10 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
/* delete the completed buf from the ctx->in chain */
if (ngx_buf_size(ctx->in->buf) == 0) {
- ctx->in = ctx->in->next;
+ cl = ctx->in;
+ ctx->in = cl->next;
+
+ ngx_free_chain(ctx->pool, cl);
}
cl = ngx_alloc_chain_link(ctx->pool);