mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Use ngx_chain_get_free_buf() in pipe input filters.
No functional changes.
This commit is contained in:
parent
7f54528ca0
commit
2576530c51
@ -857,18 +857,12 @@ ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->free) {
|
cl = ngx_chain_get_free_buf(p->pool, &p->free);
|
||||||
cl = p->free;
|
if (cl == NULL) {
|
||||||
b = cl->buf;
|
|
||||||
p->free = cl->next;
|
|
||||||
ngx_free_chain(p->pool, cl);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
b = ngx_alloc_buf(p->pool);
|
|
||||||
if (b == NULL) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
b = cl->buf;
|
||||||
|
|
||||||
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
||||||
b->shadow = buf;
|
b->shadow = buf;
|
||||||
@ -877,14 +871,6 @@ ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
b->recycled = 1;
|
b->recycled = 1;
|
||||||
buf->shadow = b;
|
buf->shadow = b;
|
||||||
|
|
||||||
cl = ngx_alloc_chain_link(p->pool);
|
|
||||||
if (cl == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl->buf = b;
|
|
||||||
cl->next = NULL;
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
||||||
|
|
||||||
if (p->in) {
|
if (p->in) {
|
||||||
|
@ -1827,18 +1827,12 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->free) {
|
cl = ngx_chain_get_free_buf(p->pool, &p->free);
|
||||||
cl = p->free;
|
if (cl == NULL) {
|
||||||
b = cl->buf;
|
|
||||||
p->free = cl->next;
|
|
||||||
ngx_free_chain(p->pool, cl);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
b = ngx_alloc_buf(p->pool);
|
|
||||||
if (b == NULL) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
b = cl->buf;
|
||||||
|
|
||||||
ngx_memzero(b, sizeof(ngx_buf_t));
|
ngx_memzero(b, sizeof(ngx_buf_t));
|
||||||
|
|
||||||
@ -1852,14 +1846,6 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
*prev = b;
|
*prev = b;
|
||||||
prev = &b->shadow;
|
prev = &b->shadow;
|
||||||
|
|
||||||
cl = ngx_alloc_chain_link(p->pool);
|
|
||||||
if (cl == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl->buf = b;
|
|
||||||
cl->next = NULL;
|
|
||||||
|
|
||||||
if (p->in) {
|
if (p->in) {
|
||||||
*p->last_in = cl;
|
*p->last_in = cl;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1615,18 +1615,12 @@ ngx_http_proxy_copy_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->free) {
|
cl = ngx_chain_get_free_buf(p->pool, &p->free);
|
||||||
cl = p->free;
|
if (cl == NULL) {
|
||||||
b = cl->buf;
|
|
||||||
p->free = cl->next;
|
|
||||||
ngx_free_chain(p->pool, cl);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
b = ngx_alloc_buf(p->pool);
|
|
||||||
if (b == NULL) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
b = cl->buf;
|
||||||
|
|
||||||
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
||||||
b->shadow = buf;
|
b->shadow = buf;
|
||||||
@ -1635,14 +1629,6 @@ ngx_http_proxy_copy_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
b->recycled = 1;
|
b->recycled = 1;
|
||||||
buf->shadow = b;
|
buf->shadow = b;
|
||||||
|
|
||||||
cl = ngx_alloc_chain_link(p->pool);
|
|
||||||
if (cl == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl->buf = b;
|
|
||||||
cl->next = NULL;
|
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
||||||
|
|
||||||
if (p->in) {
|
if (p->in) {
|
||||||
@ -1707,18 +1693,12 @@ ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
|
|
||||||
/* a chunk has been parsed successfully */
|
/* a chunk has been parsed successfully */
|
||||||
|
|
||||||
if (p->free) {
|
cl = ngx_chain_get_free_buf(p->pool, &p->free);
|
||||||
cl = p->free;
|
if (cl == NULL) {
|
||||||
b = cl->buf;
|
|
||||||
p->free = cl->next;
|
|
||||||
ngx_free_chain(p->pool, cl);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
b = ngx_alloc_buf(p->pool);
|
|
||||||
if (b == NULL) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
b = cl->buf;
|
||||||
|
|
||||||
ngx_memzero(b, sizeof(ngx_buf_t));
|
ngx_memzero(b, sizeof(ngx_buf_t));
|
||||||
|
|
||||||
@ -1732,14 +1712,6 @@ ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
|||||||
*prev = b;
|
*prev = b;
|
||||||
prev = &b->shadow;
|
prev = &b->shadow;
|
||||||
|
|
||||||
cl = ngx_alloc_chain_link(p->pool);
|
|
||||||
if (cl == NULL) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl->buf = b;
|
|
||||||
cl->next = NULL;
|
|
||||||
|
|
||||||
if (p->in) {
|
if (p->in) {
|
||||||
*p->last_in = cl;
|
*p->last_in = cl;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user