comparison src/http/modules/ngx_http_fastcgi_module.c @ 200:d2ae1c9f1fd3 NGINX_0_3_47

nginx 0.3.47 *) Feature: the "upstream" directive. *) Change: now the "\" escape symbol in the "\"" and "\'" pairs in the SSI command is always removed.
author Igor Sysoev <http://sysoev.ru>
date Tue, 23 May 2006 00:00:00 +0400
parents e6da4931e0e0
children 2a97b47ff8db
comparison
equal deleted inserted replaced
199:869664706c09 200:d2ae1c9f1fd3
9 #include <ngx_http.h> 9 #include <ngx_http.h>
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 15
16 ngx_peers_t *peers; 16 ngx_http_upstream_srv_conf_t *upstream_peers;
17 17 ngx_peers_t *peers0;
18 ngx_str_t index; 18
19 19 ngx_str_t index;
20 ngx_array_t *flushes; 20
21 ngx_array_t *params_len; 21 ngx_array_t *flushes;
22 ngx_array_t *params; 22 ngx_array_t *params_len;
23 ngx_array_t *params_source; 23 ngx_array_t *params;
24 ngx_array_t *params_source;
24 } ngx_http_fastcgi_loc_conf_t; 25 } ngx_http_fastcgi_loc_conf_t;
25 26
26 27
27 typedef enum { 28 typedef enum {
28 ngx_http_fastcgi_st_version = 0, 29 ngx_http_fastcgi_st_version = 0,
37 ngx_http_fastcgi_st_padding 38 ngx_http_fastcgi_st_padding
38 } ngx_http_fastcgi_state_e; 39 } ngx_http_fastcgi_state_e;
39 40
40 41
41 typedef struct { 42 typedef struct {
42 ngx_http_fastcgi_state_e state; 43 ngx_http_fastcgi_state_e state;
43 u_char *pos; 44 u_char *pos;
44 u_char *last; 45 u_char *last;
45 ngx_uint_t type; 46 ngx_uint_t type;
46 size_t length; 47 size_t length;
47 size_t padding; 48 size_t padding;
48 49
49 ngx_uint_t fastcgi_stdout; 50 ngx_uint_t fastcgi_stdout;
50 } ngx_http_fastcgi_ctx_t; 51 } ngx_http_fastcgi_ctx_t;
51 52
52 53
53 #define NGX_HTTP_FASTCGI_RESPONDER 1 54 #define NGX_HTTP_FASTCGI_RESPONDER 1
54 55
389 return NGX_HTTP_INTERNAL_SERVER_ERROR; 390 return NGX_HTTP_INTERNAL_SERVER_ERROR;
390 } 391 }
391 392
392 u->peer.log = r->connection->log; 393 u->peer.log = r->connection->log;
393 u->peer.log_error = NGX_ERROR_ERR; 394 u->peer.log_error = NGX_ERROR_ERR;
394 u->peer.peers = flcf->peers; 395 u->peer.peers = flcf->upstream_peers->peers;
395 u->peer.tries = flcf->peers->number; 396 u->peer.tries = flcf->upstream_peers->peers->number;
396 #if (NGX_THREADS) 397 #if (NGX_THREADS)
397 u->peer.lock = &r->connection->lock; 398 u->peer.lock = &r->connection->lock;
398 #endif 399 #endif
399 400
400 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; 401 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module;
1685 prev->upstream.max_fails, 1); 1686 prev->upstream.max_fails, 1);
1686 1687
1687 ngx_conf_merge_sec_value(conf->upstream.fail_timeout, 1688 ngx_conf_merge_sec_value(conf->upstream.fail_timeout,
1688 prev->upstream.fail_timeout, 10); 1689 prev->upstream.fail_timeout, 10);
1689 1690
1690 if (conf->peers && conf->peers->number > 1) { 1691 if (conf->upstream_peers && !conf->upstream_peers->balanced) {
1691 for (i = 0; i < conf->peers->number; i++) { 1692 for (i = 0; i < conf->upstream_peers->peers->number; i++) {
1692 conf->peers->peer[i].weight = 1; 1693 conf->upstream_peers->peers->peer[i].weight = 1;
1693 conf->peers->peer[i].max_fails = conf->upstream.max_fails; 1694 conf->upstream_peers->peers->peer[i].max_fails =
1694 conf->peers->peer[i].fail_timeout = conf->upstream.fail_timeout; 1695 conf->upstream.max_fails;
1696 conf->upstream_peers->peers->peer[i].fail_timeout =
1697 conf->upstream.fail_timeout;
1695 } 1698 }
1696 } 1699 }
1697 1700
1698 ngx_conf_merge_path_value(conf->upstream.temp_path, 1701 ngx_conf_merge_path_value(conf->upstream.temp_path,
1699 prev->upstream.temp_path, 1702 prev->upstream.temp_path,
1811 return NGX_CONF_ERROR; 1814 return NGX_CONF_ERROR;
1812 } 1815 }
1813 1816
1814 peers: 1817 peers:
1815 1818
1816 if (conf->peers == NULL) { 1819 if (conf->upstream_peers == NULL) {
1817 conf->peers = prev->peers; 1820 conf->upstream_peers = prev->upstream_peers;
1818 conf->upstream.schema = prev->upstream.schema; 1821 conf->upstream.schema = prev->upstream.schema;
1819 } 1822 }
1820 1823
1821 if (conf->params_source == NULL) { 1824 if (conf->params_source == NULL) {
1822 conf->flushes = prev->flushes; 1825 conf->flushes = prev->flushes;
1987 static char * 1990 static char *
1988 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 1991 ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1989 { 1992 {
1990 ngx_http_fastcgi_loc_conf_t *lcf = conf; 1993 ngx_http_fastcgi_loc_conf_t *lcf = conf;
1991 1994
1995 ngx_url_t u;
1992 ngx_str_t *value; 1996 ngx_str_t *value;
1993 ngx_inet_upstream_t inet_upstream;
1994 ngx_http_core_loc_conf_t *clcf; 1997 ngx_http_core_loc_conf_t *clcf;
1995 #if (NGX_HAVE_UNIX_DOMAIN)
1996 ngx_unix_domain_upstream_t unix_upstream;
1997 #endif
1998 1998
1999 if (lcf->upstream.schema.len) { 1999 if (lcf->upstream.schema.len) {
2000 return "is duplicate"; 2000 return "is duplicate";
2001 } 2001 }
2002 2002
2003 value = cf->args->elts; 2003 value = cf->args->elts;
2004 2004
2005 if (ngx_strncasecmp(value[1].data, "unix:", 5) == 0) { 2005 ngx_memzero(&u, sizeof(ngx_url_t));
2006 2006
2007 #if (NGX_HAVE_UNIX_DOMAIN) 2007 u.url = value[1];
2008 2008 u.upstream = 1;
2009 ngx_memzero(&unix_upstream, sizeof(ngx_unix_domain_upstream_t)); 2009
2010 2010 lcf->upstream_peers = ngx_http_upstream_add(cf, &u);
2011 unix_upstream.name = value[1]; 2011 if (lcf->upstream_peers == NULL) {
2012 unix_upstream.url = value[1];
2013
2014 lcf->peers = ngx_unix_upstream_parse(cf, &unix_upstream);
2015 if (lcf->peers == NULL) {
2016 return NGX_CONF_ERROR;
2017 }
2018
2019 lcf->peers->peer[0].uri_separator = "";
2020
2021 #else
2022 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2023 "the unix domain sockets are not supported "
2024 "on this platform");
2025 return NGX_CONF_ERROR; 2012 return NGX_CONF_ERROR;
2026
2027 #endif
2028
2029 } else {
2030 ngx_memzero(&inet_upstream, sizeof(ngx_inet_upstream_t));
2031
2032 inet_upstream.name = value[1];
2033 inet_upstream.url = value[1];
2034
2035 lcf->peers = ngx_inet_upstream_parse(cf, &inet_upstream);
2036 if (lcf->peers == NULL) {
2037 return NGX_CONF_ERROR;
2038 }
2039 } 2013 }
2040 2014
2041 lcf->upstream.schema.len = sizeof("fastcgi://") - 1; 2015 lcf->upstream.schema.len = sizeof("fastcgi://") - 1;
2042 lcf->upstream.schema.data = (u_char *) "fastcgi://"; 2016 lcf->upstream.schema.data = (u_char *) "fastcgi://";
2043 2017