comparison src/http/ngx_http_request.c @ 439:4fe393d82f44

nginx-0.0.12-2004-09-26-23:01:48 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 26 Sep 2004 19:01:48 +0000
parents e56ab5ac8c65
children da8c5707af39
comparison
equal deleted inserted replaced
438:e56ab5ac8c65 439:4fe393d82f44
1567 1567
1568 /* the pipelined request */ 1568 /* the pipelined request */
1569 1569
1570 if (b != c->buffer) { 1570 if (b != c->buffer) {
1571 1571
1572 /* 1572 /* move the large header buffers to the free list */
1573 * If the large header buffers were allocated while the previous
1574 * request processing then we do not use c->buffer for
1575 * the pipelined request (see ngx_http_init_request()).
1576 *
1577 * Now we would move the large header buffers to the free list.
1578 */
1579 1573
1580 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 1574 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1581 1575
1582 if (hc->free == NULL) { 1576 if (hc->free == NULL) {
1583 hc->free = ngx_palloc(c->pool, 1577 hc->free = ngx_palloc(c->pool,
1625 return; 1619 return;
1626 } 1620 }
1627 1621
1628 hc->pipeline = 0; 1622 hc->pipeline = 0;
1629 1623
1630
1631 /*
1632 * To keep a memory footprint as small as possible for an idle
1633 * keepalive connection we try to free the ngx_http_request_t and
1634 * c->buffer's memory if they were allocated outside the c->pool.
1635 * The large header buffers are always allocated outside the c->pool and
1636 * are freed too.
1637 */
1638
1639 if (ngx_pfree(c->pool, r) == NGX_OK) { 1624 if (ngx_pfree(c->pool, r) == NGX_OK) {
1640 hc->request = NULL; 1625 hc->request = NULL;
1641 } 1626 }
1642 1627
1643 b = c->buffer; 1628 b = c->buffer;
1644 1629
1645 if (ngx_pfree(c->pool, b->start) == NGX_OK) { 1630 if (ngx_pfree(c->pool, b->start) == NGX_OK) {
1646
1647 /*
1648 * the special note for ngx_http_keepalive_handler() that
1649 * c->buffer's memory was freed
1650 */
1651
1652 b->pos = NULL; 1631 b->pos = NULL;
1653 1632
1654 } else { 1633 } else {
1655 b->pos = b->start; 1634 b->pos = b->start;
1656 b->last = b->start; 1635 b->last = b->start;
1709 } 1688 }
1710 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; 1689 c->tcp_nopush = NGX_TCP_NOPUSH_UNSET;
1711 } 1690 }
1712 1691
1713 #if 0 1692 #if 0
1714 /* if ngx_http_request_t was freed then we need some other place */ 1693 /* if "keepalive_buffers off" then we need some other place */
1715 r->http_state = NGX_HTTP_KEEPALIVE_STATE; 1694 r->http_state = NGX_HTTP_KEEPALIVE_STATE;
1716 #endif 1695 #endif
1717 1696
1718 if (rev->ready) { 1697 if (rev->ready) {
1719 ngx_http_keepalive_handler(rev); 1698 ngx_http_keepalive_handler(rev);
1758 hc = c->data; 1737 hc = c->data;
1759 b = c->buffer; 1738 b = c->buffer;
1760 size = b->end - b->start; 1739 size = b->end - b->start;
1761 1740
1762 if (b->pos == NULL) { 1741 if (b->pos == NULL) {
1763
1764 /*
1765 * The c->buffer's memory was freed by ngx_http_set_keepalive().
1766 * However, the c->buffer->start and c->buffer->end were not changed
1767 * to keep the buffer size.
1768 */
1769
1770 if (!(b->pos = ngx_palloc(c->pool, size))) { 1742 if (!(b->pos = ngx_palloc(c->pool, size))) {
1771 ngx_http_close_connection(c); 1743 ngx_http_close_connection(c);
1772 return; 1744 return;
1773 } 1745 }
1774 1746