comparison src/http/modules/ngx_http_fastcgi_module.c @ 260:0effe91f6083 NGINX_0_5_0

nginx 0.5.0 *) Change: the parameters in the "%name" form in the "log_format" directive are not supported anymore. *) Change: the "proxy_upstream_max_fails", "proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails", "fastcgi_upstream_fail_timeout", "memcached_upstream_max_fails", and "memcached_upstream_fail_timeout" directives are not supported anymore. *) Feature: the "server" directive in the "upstream" context supports the "max_fails", "fail_timeout", and "down" parameters. *) Feature: the "ip_hash" directive inside the "upstream" block. *) Feature: the WAIT status in the "Auth-Status" header line of the IMAP/POP3 proxy authentication server response. *) Bugfix: nginx could not be built on 64-bit platforms; bug appeared in 0.4.14.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Dec 2006 00:00:00 +0300
parents acd2ec3541cb
children e0b1d0a6c629
comparison
equal deleted inserted replaced
259:c68f18041059 260:0effe91f6083
10 #include <nginx.h> 10 #include <nginx.h>
11 11
12 12
13 typedef struct { 13 typedef struct {
14 ngx_http_upstream_conf_t upstream; 14 ngx_http_upstream_conf_t upstream;
15
16 ngx_http_upstream_srv_conf_t *upstream_peers;
17 ngx_peers_t *peers0;
18 15
19 ngx_str_t index; 16 ngx_str_t index;
20 17
21 ngx_array_t *flushes; 18 ngx_array_t *flushes;
22 ngx_array_t *params_len; 19 ngx_array_t *params_len;
119 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, 116 static char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
120 void *conf); 117 void *conf);
121 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post, 118 static char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post,
122 void *data); 119 void *data);
123 120
121 static char *ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf,
122 ngx_command_t *cmd, void *conf);
123 static char *ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
124 ngx_command_t *cmd, void *conf);
125
124 126
125 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = { 127 static ngx_http_fastcgi_request_start_t ngx_http_fastcgi_request_start = {
126 { 1, /* version */ 128 { 1, /* version */
127 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */ 129 NGX_HTTP_FASTCGI_BEGIN_REQUEST, /* type */
128 0, /* request_id_hi */ 130 0, /* request_id_hi */
308 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), 310 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream),
309 &ngx_http_fastcgi_next_upstream_masks }, 311 &ngx_http_fastcgi_next_upstream_masks },
310 312
311 { ngx_string("fastcgi_upstream_max_fails"), 313 { ngx_string("fastcgi_upstream_max_fails"),
312 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 314 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
313 ngx_conf_set_num_slot, 315 ngx_http_fastcgi_upstream_max_fails_unsupported,
314 NGX_HTTP_LOC_CONF_OFFSET, 316 0,
315 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.max_fails), 317 0,
316 NULL }, 318 NULL },
317 319
318 { ngx_string("fastcgi_upstream_fail_timeout"), 320 { ngx_string("fastcgi_upstream_fail_timeout"),
319 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, 321 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
320 ngx_conf_set_sec_slot, 322 ngx_http_fastcgi_upstream_fail_timeout_unsupported,
321 NGX_HTTP_LOC_CONF_OFFSET, 323 0,
322 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.fail_timeout), 324 0,
323 NULL }, 325 NULL },
324 326
325 { ngx_string("fastcgi_param"), 327 { ngx_string("fastcgi_param"),
326 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, 328 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
327 ngx_conf_set_keyval_slot, 329 ngx_conf_set_keyval_slot,
409 return NGX_HTTP_INTERNAL_SERVER_ERROR; 411 return NGX_HTTP_INTERNAL_SERVER_ERROR;
410 } 412 }
411 413
412 u->peer.log = r->connection->log; 414 u->peer.log = r->connection->log;
413 u->peer.log_error = NGX_ERROR_ERR; 415 u->peer.log_error = NGX_ERROR_ERR;
414 u->peer.peers = flcf->upstream_peers->peers;
415 u->peer.tries = flcf->upstream_peers->peers->number;
416 #if (NGX_THREADS) 416 #if (NGX_THREADS)
417 u->peer.lock = &r->connection->lock; 417 u->peer.lock = &r->connection->lock;
418 #endif 418 #endif
419 419
420 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; 420 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module;
1545 1545
1546 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; 1546 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE;
1547 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; 1547 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;
1548 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; 1548 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
1549 1549
1550 conf->upstream.max_fails = NGX_CONF_UNSET_UINT;
1551 conf->upstream.fail_timeout = NGX_CONF_UNSET;
1552
1553 conf->upstream.pass_request_headers = NGX_CONF_UNSET; 1550 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
1554 conf->upstream.pass_request_body = NGX_CONF_UNSET; 1551 conf->upstream.pass_request_body = NGX_CONF_UNSET;
1555 1552
1556 conf->upstream.intercept_errors = NGX_CONF_UNSET; 1553 conf->upstream.intercept_errors = NGX_CONF_UNSET;
1557 1554
1571 u_char *p; 1568 u_char *p;
1572 size_t size; 1569 size_t size;
1573 uintptr_t *code; 1570 uintptr_t *code;
1574 ngx_str_t *header; 1571 ngx_str_t *header;
1575 ngx_uint_t i, j; 1572 ngx_uint_t i, j;
1576 ngx_peer_t *peer;
1577 ngx_array_t hide_headers; 1573 ngx_array_t hide_headers;
1578 ngx_keyval_t *src; 1574 ngx_keyval_t *src;
1579 ngx_hash_key_t *hk; 1575 ngx_hash_key_t *hk;
1580 ngx_hash_init_t hash; 1576 ngx_hash_init_t hash;
1581 ngx_http_script_compile_t sc; 1577 ngx_http_script_compile_t sc;
1705 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { 1701 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) {
1706 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET 1702 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET
1707 |NGX_HTTP_UPSTREAM_FT_OFF; 1703 |NGX_HTTP_UPSTREAM_FT_OFF;
1708 } 1704 }
1709 1705
1710 ngx_conf_merge_uint_value(conf->upstream.max_fails,
1711 prev->upstream.max_fails, 1);
1712
1713 ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
1714 prev->upstream.fail_timeout, 10);
1715
1716 if (conf->upstream_peers) {
1717 peer = conf->upstream_peers->peers->peer;
1718 for (i = 0; i < conf->upstream_peers->peers->number; i++) {
1719 ngx_conf_init_uint_value(peer[i].weight, 1);
1720 peer[i].current_weight = peer[i].weight;
1721 ngx_conf_init_uint_value(peer[i].max_fails,
1722 conf->upstream.max_fails);
1723 ngx_conf_init_value(peer[i].fail_timeout,
1724 conf->upstream.fail_timeout);
1725 }
1726
1727 }
1728
1729 ngx_conf_merge_path_value(conf->upstream.temp_path, 1706 ngx_conf_merge_path_value(conf->upstream.temp_path,
1730 prev->upstream.temp_path, 1707 prev->upstream.temp_path,
1731 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0, 1708 NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
1732 ngx_garbage_collector_temp_handler, cf); 1709 ngx_garbage_collector_temp_handler, cf);
1733 1710
1842 return NGX_CONF_ERROR; 1819 return NGX_CONF_ERROR;
1843 } 1820 }
1844 1821
1845 peers: 1822 peers:
1846 1823
1847 if (conf->upstream_peers == NULL) { 1824 if (conf->upstream.upstream == NULL) {
1848 conf->upstream_peers = prev->upstream_peers; 1825 conf->upstream.upstream = prev->upstream.upstream;
1849 conf->upstream.schema = prev->upstream.schema; 1826 conf->upstream.schema = prev->upstream.schema;
1850 } 1827 }
1851 1828
1852 if (conf->params_source == NULL) { 1829 if (conf->params_source == NULL) {
1853 conf->flushes = prev->flushes; 1830 conf->flushes = prev->flushes;
2031 value = cf->args->elts; 2008 value = cf->args->elts;
2032 2009
2033 ngx_memzero(&u, sizeof(ngx_url_t)); 2010 ngx_memzero(&u, sizeof(ngx_url_t));
2034 2011
2035 u.url = value[1]; 2012 u.url = value[1];
2036 u.upstream = 1; 2013 u.no_resolve = 1;
2037 2014
2038 lcf->upstream_peers = ngx_http_upstream_add(cf, &u); 2015 lcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
2039 if (lcf->upstream_peers == NULL) { 2016 if (lcf->upstream.upstream == NULL) {
2040 return NGX_CONF_ERROR; 2017 return NGX_CONF_ERROR;
2041 } 2018 }
2042 2019
2043 lcf->upstream.schema.len = sizeof("fastcgi://") - 1; 2020 lcf->upstream.schema.len = sizeof("fastcgi://") - 1;
2044 lcf->upstream.schema.data = (u_char *) "fastcgi://"; 2021 lcf->upstream.schema.data = (u_char *) "fastcgi://";
2082 2059
2083 #endif 2060 #endif
2084 2061
2085 return NGX_CONF_OK; 2062 return NGX_CONF_OK;
2086 } 2063 }
2064
2065
2066 static char *
2067 ngx_http_fastcgi_upstream_max_fails_unsupported(ngx_conf_t *cf,
2068 ngx_command_t *cmd, void *conf)
2069 {
2070 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2071 "\"fastcgi_upstream_max_fails\" is not supported, "
2072 "use the \"max_fails\" parameter of the \"server\" directive ",
2073 "inside the \"upstream\" block");
2074
2075 return NGX_CONF_ERROR;
2076 }
2077
2078
2079 static char *
2080 ngx_http_fastcgi_upstream_fail_timeout_unsupported(ngx_conf_t *cf,
2081 ngx_command_t *cmd, void *conf)
2082 {
2083 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2084 "\"fastcgi_upstream_fail_timeout\" is not supported, "
2085 "use the \"fail_timeout\" parameter of the \"server\" directive ",
2086 "inside the \"upstream\" block");
2087
2088 return NGX_CONF_ERROR;
2089 }