comparison src/http/ngx_http_request.c @ 326:9fc4ab6673f9 NGINX_0_6_7

nginx 0.6.7 *) Change: now the paths specified in the "include", "auth_basic_user_file", "perl_modules", "ssl_certificate", "ssl_certificate_key", and "ssl_client_certificate" directives are relative to directory of nginx configuration file nginx.conf, but not to nginx prefix directory. *) Change: the --sysconfdir=PATH option in configure was canceled. *) Change: the special make target "upgrade1" was defined for online upgrade of 0.1.x versions. *) Feature: the "server_name" and "valid_referers" directives support regular expressions. *) Feature: the "server" directive in the "upstream" context supports the "backup" parameter. *) Feature: the ngx_http_perl_module supports the $r->discard_request_body. *) Feature: the "add_header Last-Modified ..." directive changes the "Last-Modified" response header line. *) Bugfix: if an response different than 200 was returned to an request with body and connection went to the keep-alive state after the request, then nginx returned 400 for the next request. *) Bugfix: a segmentation fault occurred in worker process if invalid address was set in the "auth_http" directive. *) Bugfix: now nginx uses default listen backlog value 511 on all platforms except FreeBSD. Thanks to Jiang Hong. *) Bugfix: a worker process may got caught in an endless loop, if an "server" inside "upstream" block was marked as "down"; bug appeared in 0.6.6. *) Bugfix: now Solaris sendfilev() is not used to transfer the client request body to FastCGI-server via the unix domain socket.
author Igor Sysoev <http://sysoev.ru>
date Wed, 15 Aug 2007 00:00:00 +0400
parents fc223117327f
children 5e3b425174f6
comparison
equal deleted inserted replaced
325:f395c7a4c8a8 326:9fc4ab6673f9
31 31
32 static void ngx_http_request_handler(ngx_event_t *ev); 32 static void ngx_http_request_handler(ngx_event_t *ev);
33 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r); 33 static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r);
34 static void ngx_http_writer(ngx_http_request_t *r); 34 static void ngx_http_writer(ngx_http_request_t *r);
35 35
36 static void ngx_http_block_read(ngx_http_request_t *r); 36 static void ngx_http_test_reading(ngx_http_request_t *r);
37 static void ngx_http_test_read(ngx_http_request_t *r);
38 static void ngx_http_set_keepalive(ngx_http_request_t *r); 37 static void ngx_http_set_keepalive(ngx_http_request_t *r);
39 static void ngx_http_keepalive_handler(ngx_event_t *ev); 38 static void ngx_http_keepalive_handler(ngx_event_t *ev);
40 static void ngx_http_set_lingering_close(ngx_http_request_t *r); 39 static void ngx_http_set_lingering_close(ngx_http_request_t *r);
41 static void ngx_http_lingering_close_handler(ngx_event_t *ev); 40 static void ngx_http_lingering_close_handler(ngx_event_t *ev);
42 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); 41 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r);
1440 r->stat_writing = 1; 1439 r->stat_writing = 1;
1441 #endif 1440 #endif
1442 1441
1443 c->read->handler = ngx_http_request_handler; 1442 c->read->handler = ngx_http_request_handler;
1444 c->write->handler = ngx_http_request_handler; 1443 c->write->handler = ngx_http_request_handler;
1445 r->read_event_handler = ngx_http_block_read; 1444 r->read_event_handler = ngx_http_block_reading;
1446 1445
1447 ngx_http_handler(r); 1446 ngx_http_handler(r);
1448 1447
1449 return; 1448 return;
1450 } 1449 }
1452 1451
1453 static void 1452 static void
1454 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len, 1453 ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
1455 ngx_uint_t hash) 1454 ngx_uint_t hash)
1456 { 1455 {
1457 ngx_http_virtual_names_t *vn;
1458 ngx_http_core_loc_conf_t *clcf; 1456 ngx_http_core_loc_conf_t *clcf;
1459 ngx_http_core_srv_conf_t *cscf; 1457 ngx_http_core_srv_conf_t *cscf;
1460 1458 #if (NGX_PCRE)
1461 vn = r->virtual_names; 1459 ngx_int_t n;
1462 1460 ngx_uint_t i;
1463 cscf = ngx_hash_find_combined(vn, hash, host, len); 1461 ngx_str_t name;
1462 ngx_http_server_name_t *sn;
1463 #endif
1464
1465 cscf = ngx_hash_find_combined(&r->virtual_names->names, hash, host, len);
1464 1466
1465 if (cscf) { 1467 if (cscf) {
1466 goto found; 1468 goto found;
1467 } 1469 }
1470
1471 #if (NGX_PCRE)
1472
1473 if (r->virtual_names->nregex) {
1474
1475 name.len = len;
1476 name.data = host;
1477
1478 sn = r->virtual_names->regex;
1479
1480 for (i = 0; i < r->virtual_names->nregex; i++) {
1481
1482 n = ngx_regex_exec(sn[i].regex, &name, NULL, 0);
1483
1484 if (n == NGX_REGEX_NO_MATCHED) {
1485 continue;
1486 }
1487
1488 if (n < 0) {
1489 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1490 ngx_regex_exec_n
1491 " failed: %d on \"%V\" using \"%V\"",
1492 n, &name, &sn[i].name);
1493 return;
1494 }
1495
1496 /* match */
1497
1498 cscf = sn[i].core_srv_conf;
1499
1500 goto found;
1501 }
1502 }
1503
1504 #endif
1468 1505
1469 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 1506 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1470 1507
1471 if (cscf->wildcard) { 1508 if (cscf->wildcard) {
1472 r->server_name.len = len; 1509 r->server_name.len = len;
1700 ngx_event_t *wev; 1737 ngx_event_t *wev;
1701 ngx_http_core_loc_conf_t *clcf; 1738 ngx_http_core_loc_conf_t *clcf;
1702 1739
1703 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; 1740 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE;
1704 1741
1705 r->read_event_handler = ngx_http_test_read; 1742 r->read_event_handler = ngx_http_test_reading;
1706 r->write_event_handler = ngx_http_writer; 1743 r->write_event_handler = ngx_http_writer;
1707 1744
1708 wev = r->connection->write; 1745 wev = r->connection->write;
1709 1746
1710 if (wev->ready && wev->delayed) { 1747 if (wev->ready && wev->delayed) {
1810 1847
1811 ngx_http_finalize_request(r, rc); 1848 ngx_http_finalize_request(r, rc);
1812 } 1849 }
1813 1850
1814 1851
1815 static void 1852 void
1816 ngx_http_block_read(ngx_http_request_t *r) 1853 ngx_http_block_reading(ngx_http_request_t *r)
1817 { 1854 {
1818 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1855 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1819 "http read blocked"); 1856 "http reading blocked");
1820 1857
1821 /* aio does not call this handler */ 1858 /* aio does not call this handler */
1822 1859
1823 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) 1860 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT)
1824 && r->connection->read->active) 1861 && r->connection->read->active)
1831 } 1868 }
1832 } 1869 }
1833 1870
1834 1871
1835 static void 1872 static void
1836 ngx_http_test_read(ngx_http_request_t *r) 1873 ngx_http_test_reading(ngx_http_request_t *r)
1837 { 1874 {
1838 int n; 1875 int n;
1839 char buf[1]; 1876 char buf[1];
1840 ngx_err_t err; 1877 ngx_err_t err;
1841 ngx_event_t *rev; 1878 ngx_event_t *rev;
1842 ngx_connection_t *c; 1879 ngx_connection_t *c;
1843 1880
1844 c = r->connection; 1881 c = r->connection;
1845 rev = c->read; 1882 rev = c->read;
1846 1883
1847 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http test read"); 1884 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http test reading");
1848 1885
1849 #if (NGX_HAVE_KQUEUE) 1886 #if (NGX_HAVE_KQUEUE)
1850 1887
1851 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) { 1888 if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
1852 1889
1920 ngx_http_core_loc_conf_t *clcf; 1957 ngx_http_core_loc_conf_t *clcf;
1921 1958
1922 c = r->connection; 1959 c = r->connection;
1923 rev = c->read; 1960 rev = c->read;
1924 1961
1962 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1963
1925 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler"); 1964 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler");
1965
1966 if (r->discard_body) {
1967 r->lingering_time = ngx_time() + (time_t) (clcf->lingering_time / 1000);
1968 ngx_add_timer(rev, clcf->lingering_timeout);
1969 return;
1970 }
1926 1971
1927 c->log->action = "closing request"; 1972 c->log->action = "closing request";
1928 1973
1929 hc = r->http_connection; 1974 hc = r->http_connection;
1930 b = r->header_in; 1975 b = r->header_in;
1964 2009
1965 hc->busy[0] = b; 2010 hc->busy[0] = b;
1966 hc->nbusy = 1; 2011 hc->nbusy = 1;
1967 } 2012 }
1968 } 2013 }
1969
1970 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1971 2014
1972 ngx_http_request_done(r, 0); 2015 ngx_http_request_done(r, 0);
1973 2016
1974 c->data = hc; 2017 c->data = hc;
1975 2018
2379 2422
2380 r->http_version = NGX_HTTP_VERSION_9; 2423 r->http_version = NGX_HTTP_VERSION_9;
2381 r->header_only = 1; 2424 r->header_only = 1;
2382 r->post_action = 1; 2425 r->post_action = 1;
2383 2426
2384 r->read_event_handler = ngx_http_block_read; 2427 r->read_event_handler = ngx_http_block_reading;
2385 2428
2386 ngx_http_internal_redirect(r, &clcf->post_action, NULL); 2429 ngx_http_internal_redirect(r, &clcf->post_action, NULL);
2387 2430
2388 return NGX_OK; 2431 return NGX_OK;
2389 } 2432 }