mirror of
https://github.com/nginx/nginx.git
synced 2024-12-05 06:19:01 +08:00
API change: ngx_chain_update_chains() now requires pool.
The ngx_chain_update_chains() needs pool to free chain links used for buffers with non-matching tags. Providing one helps to reduce memory consumption for long-lived requests.
This commit is contained in:
parent
a890b313f3
commit
d7c2673d3f
@ -180,7 +180,7 @@ ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
|
ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy,
|
||||||
ngx_chain_t **out, ngx_buf_tag_t tag)
|
ngx_chain_t **out, ngx_buf_tag_t tag)
|
||||||
{
|
{
|
||||||
ngx_chain_t *cl;
|
ngx_chain_t *cl;
|
||||||
@ -197,19 +197,21 @@ ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
|
|||||||
*out = NULL;
|
*out = NULL;
|
||||||
|
|
||||||
while (*busy) {
|
while (*busy) {
|
||||||
if (ngx_buf_size((*busy)->buf) != 0) {
|
cl = *busy;
|
||||||
|
|
||||||
|
if (ngx_buf_size(cl->buf) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*busy)->buf->tag != tag) {
|
if (cl->buf->tag != tag) {
|
||||||
*busy = (*busy)->next;
|
*busy = cl->next;
|
||||||
|
ngx_free_chain(p, cl);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*busy)->buf->pos = (*busy)->buf->start;
|
cl->buf->pos = cl->buf->start;
|
||||||
(*busy)->buf->last = (*busy)->buf->start;
|
cl->buf->last = cl->buf->start;
|
||||||
|
|
||||||
cl = *busy;
|
|
||||||
*busy = cl->next;
|
*busy = cl->next;
|
||||||
cl->next = *free;
|
cl->next = *free;
|
||||||
*free = cl;
|
*free = cl;
|
||||||
|
@ -154,8 +154,8 @@ ngx_int_t ngx_chain_writer(void *ctx, ngx_chain_t *in);
|
|||||||
ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
|
ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
|
||||||
ngx_chain_t *in);
|
ngx_chain_t *in);
|
||||||
ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free);
|
ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free);
|
||||||
void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
|
void ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free,
|
||||||
ngx_chain_t **out, ngx_buf_tag_t tag);
|
ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_BUF_H_INCLUDED_ */
|
#endif /* _NGX_BUF_H_INCLUDED_ */
|
||||||
|
@ -208,7 +208,8 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
|||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out, ctx->tag);
|
ngx_chain_update_chains(ctx->pool, &ctx->free, &ctx->busy, &out,
|
||||||
|
ctx->tag);
|
||||||
last_out = &out;
|
last_out = &out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
|||||||
return ngx_event_pipe_drain_chains(p);
|
return ngx_event_pipe_drain_chains(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_chain_update_chains(&p->free, &p->busy, &out, p->tag);
|
ngx_chain_update_chains(p->pool, &p->free, &p->busy, &out, p->tag);
|
||||||
|
|
||||||
for (cl = p->free; cl; cl = cl->next) {
|
for (cl = p->free; cl; cl = cl->next) {
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
rc = ngx_http_next_body_filter(r, out);
|
rc = ngx_http_next_body_filter(r, out);
|
||||||
|
|
||||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out,
|
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &out,
|
||||||
(ngx_buf_tag_t) &ngx_http_chunked_filter_module);
|
(ngx_buf_tag_t) &ngx_http_chunked_filter_module);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -378,7 +378,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
cl = NULL;
|
cl = NULL;
|
||||||
|
|
||||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &cl,
|
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &cl,
|
||||||
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
||||||
ctx->nomem = 0;
|
ctx->nomem = 0;
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
ngx_http_gzip_filter_free_copy_buf(r, ctx);
|
ngx_http_gzip_filter_free_copy_buf(r, ctx);
|
||||||
|
|
||||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &ctx->out,
|
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &ctx->out,
|
||||||
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
(ngx_buf_tag_t) &ngx_http_gzip_filter_module);
|
||||||
ctx->last_out = &ctx->out;
|
ctx->last_out = &ctx->out;
|
||||||
|
|
||||||
|
@ -2382,7 +2382,7 @@ ngx_http_upstream_process_non_buffered_request(ngx_http_request_t *r,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_chain_update_chains(&u->free_bufs, &u->busy_bufs,
|
ngx_chain_update_chains(r->pool, &u->free_bufs, &u->busy_bufs,
|
||||||
&u->out_bufs, u->output.tag);
|
&u->out_bufs, u->output.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user