comparison src/http/modules/ngx_http_proxy_module.c @ 5466:e7b3b9855be8

Use ngx_chain_get_free_buf() in pipe input filters. No functional changes.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 11 Dec 2013 21:30:38 +0400
parents 43ccaf8e8728
children d15822784cf9
comparison
equal deleted inserted replaced
5465:a279d2a33dbf 5466:e7b3b9855be8
1613 1613
1614 if (buf->pos == buf->last) { 1614 if (buf->pos == buf->last) {
1615 return NGX_OK; 1615 return NGX_OK;
1616 } 1616 }
1617 1617
1618 if (p->free) { 1618 cl = ngx_chain_get_free_buf(p->pool, &p->free);
1619 cl = p->free; 1619 if (cl == NULL) {
1620 b = cl->buf; 1620 return NGX_ERROR;
1621 p->free = cl->next; 1621 }
1622 ngx_free_chain(p->pool, cl); 1622
1623 1623 b = cl->buf;
1624 } else {
1625 b = ngx_alloc_buf(p->pool);
1626 if (b == NULL) {
1627 return NGX_ERROR;
1628 }
1629 }
1630 1624
1631 ngx_memcpy(b, buf, sizeof(ngx_buf_t)); 1625 ngx_memcpy(b, buf, sizeof(ngx_buf_t));
1632 b->shadow = buf; 1626 b->shadow = buf;
1633 b->tag = p->tag; 1627 b->tag = p->tag;
1634 b->last_shadow = 1; 1628 b->last_shadow = 1;
1635 b->recycled = 1; 1629 b->recycled = 1;
1636 buf->shadow = b; 1630 buf->shadow = b;
1637 1631
1638 cl = ngx_alloc_chain_link(p->pool);
1639 if (cl == NULL) {
1640 return NGX_ERROR;
1641 }
1642
1643 cl->buf = b;
1644 cl->next = NULL;
1645
1646 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num); 1632 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
1647 1633
1648 if (p->in) { 1634 if (p->in) {
1649 *p->last_in = cl; 1635 *p->last_in = cl;
1650 } else { 1636 } else {
1705 1691
1706 if (rc == NGX_OK) { 1692 if (rc == NGX_OK) {
1707 1693
1708 /* a chunk has been parsed successfully */ 1694 /* a chunk has been parsed successfully */
1709 1695
1710 if (p->free) { 1696 cl = ngx_chain_get_free_buf(p->pool, &p->free);
1711 cl = p->free; 1697 if (cl == NULL) {
1712 b = cl->buf; 1698 return NGX_ERROR;
1713 p->free = cl->next; 1699 }
1714 ngx_free_chain(p->pool, cl); 1700
1715 1701 b = cl->buf;
1716 } else {
1717 b = ngx_alloc_buf(p->pool);
1718 if (b == NULL) {
1719 return NGX_ERROR;
1720 }
1721 }
1722 1702
1723 ngx_memzero(b, sizeof(ngx_buf_t)); 1703 ngx_memzero(b, sizeof(ngx_buf_t));
1724 1704
1725 b->pos = buf->pos; 1705 b->pos = buf->pos;
1726 b->start = buf->start; 1706 b->start = buf->start;
1729 b->temporary = 1; 1709 b->temporary = 1;
1730 b->recycled = 1; 1710 b->recycled = 1;
1731 1711
1732 *prev = b; 1712 *prev = b;
1733 prev = &b->shadow; 1713 prev = &b->shadow;
1734
1735 cl = ngx_alloc_chain_link(p->pool);
1736 if (cl == NULL) {
1737 return NGX_ERROR;
1738 }
1739
1740 cl->buf = b;
1741 cl->next = NULL;
1742 1714
1743 if (p->in) { 1715 if (p->in) {
1744 *p->last_in = cl; 1716 *p->last_in = cl;
1745 } else { 1717 } else {
1746 p->in = cl; 1718 p->in = cl;