comparison src/http/ngx_http_request.c @ 330:5e3b425174f6 NGINX_0_6_9

nginx 0.6.9 *) Bugfix: a worker process may got caught in an endless loop, if the HTTPS protocol was used; bug appeared in 0.6.7. *) Bugfix: if server listened on two addresses or ports and trailing wildcard was used, then nginx did not run. *) Bugfix: the "ip_hash" directive might incorrectly mark servers as down. *) Bugfix: nginx could not be built on amd64; bug appeared in 0.6.8.
author Igor Sysoev <http://sysoev.ru>
date Tue, 28 Aug 2007 00:00:00 +0400
parents 9fc4ab6673f9
children 3a91bfeffaba
comparison
equal deleted inserted replaced
329:f2f8dc3e7933 330:5e3b425174f6
834 } 834 }
835 835
836 ngx_log_error(NGX_LOG_INFO, c->log, 0, 836 ngx_log_error(NGX_LOG_INFO, c->log, 0,
837 "client sent too long header line: \"%V\"", 837 "client sent too long header line: \"%V\"",
838 &header); 838 &header);
839 ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST); 839 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
840 return; 840 return;
841 } 841 }
842 } 842 }
843 843
844 n = ngx_http_read_request_header(r); 844 n = ngx_http_read_request_header(r);
946 header.len = r->header_end - r->header_name_start; 946 header.len = r->header_end - r->header_name_start;
947 header.data = r->header_name_start; 947 header.data = r->header_name_start;
948 ngx_log_error(NGX_LOG_INFO, c->log, 0, 948 ngx_log_error(NGX_LOG_INFO, c->log, 0,
949 "client sent invalid header line: \"%V\\r...\"", 949 "client sent invalid header line: \"%V\\r...\"",
950 &header); 950 &header);
951 ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST); 951 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
952 return; 952 return;
953 } 953 }
954 } 954 }
955 955
956 956
1554 1554
1555 1555
1556 void 1556 void
1557 ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc) 1557 ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
1558 { 1558 {
1559 ngx_connection_t *c;
1559 ngx_http_request_t *pr; 1560 ngx_http_request_t *pr;
1560 ngx_http_log_ctx_t *ctx; 1561 ngx_http_log_ctx_t *ctx;
1561 ngx_http_core_loc_conf_t *clcf; 1562 ngx_http_core_loc_conf_t *clcf;
1562 1563
1563 if (rc == NGX_DONE) { 1564 if (rc == NGX_DONE) {
1564 /* the request pool may be already destroyed */ 1565 /* the request pool may be already destroyed */
1565 return; 1566 return;
1566 } 1567 }
1567 1568
1568 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1569 c = r->connection;
1570
1571 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
1569 "http finalize request: %d, \"%V?%V\"", 1572 "http finalize request: %d, \"%V?%V\"",
1570 rc, &r->uri, &r->args); 1573 rc, &r->uri, &r->args);
1571 1574
1572 if (rc == NGX_DECLINED) { 1575 if (rc == NGX_DECLINED) {
1573 r->content_handler = NULL; 1576 r->content_handler = NULL;
1578 1581
1579 if (r != r->main && r->post_subrequest) { 1582 if (r != r->main && r->post_subrequest) {
1580 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); 1583 rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);
1581 } 1584 }
1582 1585
1583 if (rc == NGX_ERROR 1586 if (rc == NGX_ERROR || rc == NGX_HTTP_REQUEST_TIME_OUT || c->error) {
1584 || rc == NGX_HTTP_REQUEST_TIME_OUT
1585 || r->connection->error)
1586 {
1587 if (rc > 0 && r->headers_out.status == 0) { 1587 if (rc > 0 && r->headers_out.status == 0) {
1588 r->headers_out.status = rc; 1588 r->headers_out.status = rc;
1589 } 1589 }
1590 1590
1591 if (ngx_http_post_action(r) == NGX_OK) { 1591 if (ngx_http_post_action(r) == NGX_OK) {
1604 ngx_http_close_request(r, rc); 1604 ngx_http_close_request(r, rc);
1605 return; 1605 return;
1606 } 1606 }
1607 1607
1608 if (r == r->main) { 1608 if (r == r->main) {
1609 if (r->connection->read->timer_set) { 1609 if (c->read->timer_set) {
1610 ngx_del_timer(r->connection->read); 1610 ngx_del_timer(c->read);
1611 } 1611 }
1612 1612
1613 if (r->connection->write->timer_set) { 1613 if (c->write->timer_set) {
1614 ngx_del_timer(r->connection->write); 1614 ngx_del_timer(c->write);
1615 } 1615 }
1616 } 1616 }
1617 1617
1618 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 1618 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
1619 return; 1619 return;
1625 } 1625 }
1626 } 1626 }
1627 1627
1628 r->done = 1; 1628 r->done = 1;
1629 1629
1630 if (r != r->connection->data) { 1630 if (r != c->data) {
1631 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1631 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1632 "http finalize non-active request: \"%V?%V\"", 1632 "http finalize non-active request: \"%V?%V\"",
1633 &r->uri, &r->args); 1633 &r->uri, &r->args);
1634 return; 1634 return;
1635 } 1635 }
1636 1636
1637 if (r != r->main) { 1637 if (r != r->main) {
1638 1638
1639 pr = r->parent; 1639 pr = r->parent;
1640 1640
1641 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1641 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1642 "http parent request: \"%V?%V\"", &pr->uri, &pr->args); 1642 "http parent request: \"%V?%V\"", &pr->uri, &pr->args);
1643 1643
1644 if (rc != NGX_AGAIN) { 1644 if (rc != NGX_AGAIN) {
1645 r->connection->data = pr; 1645 c->data = pr;
1646 } 1646 }
1647 1647
1648 ctx = r->connection->log->data; 1648 ctx = c->log->data;
1649 ctx->current_request = pr; 1649 ctx->current_request = pr;
1650 1650
1651 if (pr->postponed) { 1651 if (pr->postponed) {
1652 1652
1653 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1653 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1654 "http request: \"%V?%V\" has postponed", 1654 "http request: \"%V?%V\" has postponed",
1655 &pr->uri, &pr->args); 1655 &pr->uri, &pr->args);
1656 1656
1657 if (rc != NGX_AGAIN && pr->postponed->request == r) { 1657 if (rc != NGX_AGAIN && pr->postponed->request == r) {
1658 pr->postponed = pr->postponed->next; 1658 pr->postponed = pr->postponed->next;
1662 1662
1663 if (rc == NGX_AGAIN) { 1663 if (rc == NGX_AGAIN) {
1664 r->fast_subrequest = 0; 1664 r->fast_subrequest = 0;
1665 } 1665 }
1666 1666
1667 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1667 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1668 "http fast subrequest: \"%V?%V\" done", 1668 "http fast subrequest: \"%V?%V\" done",
1669 &r->uri, &r->args); 1669 &r->uri, &r->args);
1670 return; 1670 return;
1671 } 1671 }
1672 1672
1673 if (rc != NGX_AGAIN) { 1673 if (rc != NGX_AGAIN) {
1674 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1674 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1675 "http wake parent request: \"%V?%V\"", 1675 "http wake parent request: \"%V?%V\"",
1676 &pr->uri, &pr->args); 1676 &pr->uri, &pr->args);
1677 1677
1678 pr->write_event_handler(pr); 1678 pr->write_event_handler(pr);
1679 } 1679 }
1684 1684
1685 if (rc == NGX_AGAIN) { 1685 if (rc == NGX_AGAIN) {
1686 return; 1686 return;
1687 } 1687 }
1688 1688
1689 if (r->connection->buffered) { 1689 if (c->buffered) {
1690 (void) ngx_http_set_write_handler(r); 1690 (void) ngx_http_set_write_handler(r);
1691 return; 1691 return;
1692 } 1692 }
1693 1693
1694 if (!r->post_action) { 1694 if (!r->post_action) {
1697 1697
1698 if (ngx_http_post_action(r) == NGX_OK) { 1698 if (ngx_http_post_action(r) == NGX_OK) {
1699 return; 1699 return;
1700 } 1700 }
1701 1701
1702 if (r->connection->read->timer_set) { 1702 if (c->read->timer_set) {
1703 ngx_del_timer(r->connection->read); 1703 ngx_del_timer(c->read);
1704 } 1704 }
1705 1705
1706 if (r->connection->write->timer_set) { 1706 if (c->write->timer_set) {
1707 r->connection->write->delayed = 0; 1707 c->write->delayed = 0;
1708 ngx_del_timer(r->connection->write); 1708 ngx_del_timer(c->write);
1709 } 1709 }
1710 1710
1711 if (r->connection->destroyed) { 1711 if (c->destroyed) {
1712 return;
1713 }
1714
1715 if (c->read->eof) {
1716 ngx_http_close_request(r, 0);
1712 return; 1717 return;
1713 } 1718 }
1714 1719
1715 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 1720 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1716 1721