annotate src/http/ngx_http.c @ 198:e6da4931e0e0 NGINX_0_3_46

nginx 0.3.46 *) Feature: the "proxy_hide_header", "proxy_pass_header", "fastcgi_hide_header", and "fastcgi_pass_header" directives. *) Change: the "proxy_pass_x_powered_by", "fastcgi_x_powered_by", and "proxy_pass_server" directives were canceled. *) Feature: the "X-Accel-Buffering" response header line is supported in proxy mode. *) Bugfix: the reconfiguration bug and memory leaks in the ngx_http_perl_module.
author Igor Sysoev <http://sysoev.ru>
date Thu, 11 May 2006 00:00:00 +0400
parents 3689cd4e3228
children 38e7b94d63ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_event.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10 #include <ngx_http.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
14 static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
15 ngx_http_conf_in_port_t *in_port, ngx_http_listen_t *lscf,
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
16 ngx_http_core_srv_conf_t *cscf);
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
17 static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
18 ngx_http_conf_in_addr_t *in_addr, ngx_http_core_srv_conf_t *cscf);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
19 static char *ngx_http_merge_locations(ngx_conf_t *cf,
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
20 ngx_array_t *locations, void **loc_conf, ngx_http_module_t *module,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
21 ngx_uint_t ctx_index);
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
22 static int ngx_libc_cdecl ngx_http_cmp_conf_in_addrs(const void *one,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
23 const void *two);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
24 static int ngx_libc_cdecl ngx_http_cmp_dns_wildcards(const void *one,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
25 const void *two);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
26
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
27 ngx_uint_t ngx_http_max_module;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
28
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
29 ngx_uint_t ngx_http_total_requests;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
30 uint64_t ngx_http_total_sent;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
33 ngx_int_t (*ngx_http_top_header_filter) (ngx_http_request_t *r);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 ngx_int_t (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
36
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37 static ngx_command_t ngx_http_commands[] = {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
39 { ngx_string("http"),
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
40 NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
41 ngx_http_block,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
42 0,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
43 0,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
44 NULL },
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
46 ngx_null_command
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47 };
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
49
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50 static ngx_core_module_t ngx_http_module_ctx = {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
51 ngx_string("http"),
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52 NULL,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53 NULL
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
54 };
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57 ngx_module_t ngx_http_module = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
58 NGX_MODULE_V1,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 &ngx_http_module_ctx, /* module context */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60 ngx_http_commands, /* module directives */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 NGX_CORE_MODULE, /* module type */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
62 NULL, /* init master */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
63 NULL, /* init module */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
64 NULL, /* init process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
65 NULL, /* init thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
66 NULL, /* exit thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
67 NULL, /* exit process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
68 NULL, /* exit master */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 72
diff changeset
69 NGX_MODULE_V1_PADDING
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
70 };
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
73 static char *
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
74 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
75 {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
76 char *rv;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
77 u_char ch;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
78 ngx_int_t rc;
152
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
79 ngx_uint_t mi, m, s, l, p, a, i;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
80 ngx_uint_t last, bind_all, done;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81 ngx_conf_t pcf;
198
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
82 ngx_array_t headers_in, in_ports;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
83 ngx_hash_key_t *hk;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
84 ngx_hash_init_t hash;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85 ngx_listening_t *ls;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
86 ngx_http_listen_t *lscf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
87 ngx_http_module_t *module;
198
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
88 ngx_http_header_t *header;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
89 ngx_http_in_port_t *hip;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
90 ngx_http_handler_pt *h;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
91 ngx_http_conf_ctx_t *ctx;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
92 ngx_http_conf_in_port_t *in_port;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
93 ngx_http_conf_in_addr_t *in_addr;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
94 ngx_hash_keys_arrays_t ha;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
95 ngx_http_server_name_t *name;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
96 ngx_http_virtual_names_t *vn;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
97 ngx_http_core_srv_conf_t **cscfp, *cscf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
98 ngx_http_core_loc_conf_t *clcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
99 ngx_http_core_main_conf_t *cmcf;
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
100 #if (NGX_WIN32)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
101 ngx_iocp_conf_t *iocpcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
102 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
103
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
104 /* the main http context */
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
105
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
106 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
107 if (ctx == NULL) {
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
108 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
109 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
110
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
111 *(ngx_http_conf_ctx_t **) conf = ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
112
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
113
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
114 /* count the number of the http modules and set up their indices */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
115
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
116 ngx_http_max_module = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
117 for (m = 0; ngx_modules[m]; m++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
118 if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
119 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
120 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
121
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
122 ngx_modules[m]->ctx_index = ngx_http_max_module++;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
123 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
124
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
125
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
126 /* the http main_conf context, it is the same in the all http contexts */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
127
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
128 ctx->main_conf = ngx_pcalloc(cf->pool,
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
129 sizeof(void *) * ngx_http_max_module);
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
130 if (ctx->main_conf == NULL) {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
131 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
132 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
133
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
134
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
135 /*
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
136 * the http null srv_conf context, it is used to merge
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
137 * the server{}s' srv_conf's
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
138 */
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
139
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
140 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
141 if (ctx->srv_conf == NULL) {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
142 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
143 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
144
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
145
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
146 /*
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
147 * the http null loc_conf context, it is used to merge
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
148 * the server{}s' loc_conf's
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
149 */
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
150
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
151 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
152 if (ctx->loc_conf == NULL) {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
153 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
154 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
155
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
156
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
157 /*
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
158 * create the main_conf's, the null srv_conf's, and the null loc_conf's
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
159 * of the all http modules
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
160 */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
161
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
162 for (m = 0; ngx_modules[m]; m++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
163 if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
164 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
165 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
166
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
167 module = ngx_modules[m]->ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
168 mi = ngx_modules[m]->ctx_index;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
169
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
170 if (module->create_main_conf) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
171 ctx->main_conf[mi] = module->create_main_conf(cf);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
172 if (ctx->main_conf[mi] == NULL) {
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
173 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
174 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
175 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
176
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
177 if (module->create_srv_conf) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
178 ctx->srv_conf[mi] = module->create_srv_conf(cf);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
179 if (ctx->srv_conf[mi] == NULL) {
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
180 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
181 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
183
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
184 if (module->create_loc_conf) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
185 ctx->loc_conf[mi] = module->create_loc_conf(cf);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
186 if (ctx->loc_conf[mi] == NULL) {
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
187 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
188 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
189 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
190 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
191
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
192 pcf = *cf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
193 cf->ctx = ctx;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
194
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
195 for (m = 0; ngx_modules[m]; m++) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
196 if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
197 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
198 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
199
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
200 module = ngx_modules[m]->ctx;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
201 mi = ngx_modules[m]->ctx_index;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
202
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
203 if (module->preconfiguration) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
204 if (module->preconfiguration(cf) != NGX_OK) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
205 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
206 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
207 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
208 }
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
209
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
210 /* parse inside the http{} block */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
211
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
212 cf->module_type = NGX_HTTP_MODULE;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
213 cf->cmd_type = NGX_HTTP_MAIN_CONF;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
214 rv = ngx_conf_parse(cf, NULL);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
215
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
216 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
217 *cf = pcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
218 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
219 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
220
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
221 /*
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
222 * init http{} main_conf's, merge the server{}s' srv_conf's
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
223 * and its location{}s' loc_conf's
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
224 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
225
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
226 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
227 cscfp = cmcf->servers.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
228
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
229 for (m = 0; ngx_modules[m]; m++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
230 if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
231 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
232 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
233
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
234 module = ngx_modules[m]->ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
235 mi = ngx_modules[m]->ctx_index;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
236
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
237 /* init http{} main_conf's */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
238
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
239 if (module->init_main_conf) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
240 rv = module->init_main_conf(cf, ctx->main_conf[mi]);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
241 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
242 *cf = pcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
243 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
244 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
245 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
246
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
247 for (s = 0; s < cmcf->servers.nelts; s++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
248
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
249 /* merge the server{}s' srv_conf's */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
250
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
251 if (module->merge_srv_conf) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
252 rv = module->merge_srv_conf(cf,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
253 ctx->srv_conf[mi],
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
254 cscfp[s]->ctx->srv_conf[mi]);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
255 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
256 *cf = pcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
257 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
258 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
259 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
260
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
261 if (module->merge_loc_conf) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
262
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
263 /* merge the server{}'s loc_conf */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
264
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
265 rv = module->merge_loc_conf(cf,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
266 ctx->loc_conf[mi],
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
267 cscfp[s]->ctx->loc_conf[mi]);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
268 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
269 *cf = pcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
270 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
271 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
272
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
273 /* merge the locations{}' loc_conf's */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
274
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
275 rv = ngx_http_merge_locations(cf, &cscfp[s]->locations,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
276 cscfp[s]->ctx->loc_conf,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
277 module, mi);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
278 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
279 *cf = pcf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
280 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
281 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
282 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
283 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
284 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
285
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
286
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
287 /* init lists of the handlers */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
288
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
289 if (ngx_array_init(&cmcf->phases[NGX_HTTP_POST_READ_PHASE].handlers,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
290 cf->pool, 1, sizeof(ngx_http_handler_pt))
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
291 != NGX_OK)
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
292 {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
293 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
294 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
295
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
296 cmcf->phases[NGX_HTTP_POST_READ_PHASE].type = NGX_OK;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
297
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
298
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
299 if (ngx_array_init(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
300 cf->pool, 1, sizeof(ngx_http_handler_pt))
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
301 != NGX_OK)
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
302 {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
303 return NGX_CONF_ERROR;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
304 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
305
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
306 cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].type = NGX_OK;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
307
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
308
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
309 /* the special find config phase for a single handler */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
310
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
311 if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers,
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
312 cf->pool, 1, sizeof(ngx_http_handler_pt))
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
313 != NGX_OK)
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
314 {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
315 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
316 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
317
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
318 cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
319
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
320 h = ngx_array_push(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers);
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
321 if (h == NULL) {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
322 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
323 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
324
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
325 *h = ngx_http_find_location_config;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
326
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
327
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
328 if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
329 cf->pool, 1, sizeof(ngx_http_handler_pt))
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
330 != NGX_OK)
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
331 {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
332 return NGX_CONF_ERROR;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
333 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
334
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
335 cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
336
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
337
130
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
338 if (ngx_array_init(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers,
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
339 cf->pool, 1, sizeof(ngx_http_handler_pt))
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
340 != NGX_OK)
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
341 {
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
342 return NGX_CONF_ERROR;
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
343 }
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
344
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
345 cmcf->phases[NGX_HTTP_PREACCESS_PHASE].type = NGX_OK;
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
346
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
347
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
348 if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers,
130
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
349 cf->pool, 2, sizeof(ngx_http_handler_pt))
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
350 != NGX_OK)
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
351 {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
352 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
353 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
354
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
355 cmcf->phases[NGX_HTTP_ACCESS_PHASE].type = NGX_DECLINED;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
356
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
357
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
358 if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers,
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
359 cf->pool, 4, sizeof(ngx_http_handler_pt))
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
360 != NGX_OK)
34
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
361 {
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
362 return NGX_CONF_ERROR;
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
363 }
aab2ea7c0458 nginx 0.1.17
Igor Sysoev <http://sysoev.ru>
parents: 26
diff changeset
364
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
365 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
366
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
367
130
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
368 if (ngx_array_init(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers,
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
369 cf->pool, 1, sizeof(ngx_http_handler_pt))
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
370 != NGX_OK)
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
371 {
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
372 return NGX_CONF_ERROR;
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
373 }
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
374
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
375 cmcf->phases[NGX_HTTP_LOG_PHASE].type = NGX_OK;
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
376
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
377
198
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
378 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t))
56
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
379 != NGX_OK)
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
380 {
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
381 return NGX_CONF_ERROR;
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
382 }
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
383
198
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
384 for (header = ngx_http_headers_in; header->name.len; header++) {
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
385 hk = ngx_array_push(&headers_in);
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
386 if (hk == NULL) {
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
387 return NGX_CONF_ERROR;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
388 }
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
389
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
390 hk->key = header->name;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
391 hk->key_hash = ngx_hash_key_lc(header->name.data, header->name.len);
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
392 hk->value = header;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
393 }
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
394
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
395 hash.hash = &cmcf->headers_in_hash;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
396 hash.key = ngx_hash_key_lc;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
397 hash.max_size = 512;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
398 hash.bucket_size = ngx_cacheline_size;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
399 hash.name = "headers_in_hash";
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
400 hash.pool = cf->pool;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
401 hash.temp_pool = NULL;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
402
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
403 if (ngx_hash_init(&hash, headers_in.elts, headers_in.nelts) != NGX_OK) {
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
404 return NGX_CONF_ERROR;
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
405 }
e6da4931e0e0 nginx 0.3.46
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
406
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
407
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
408 for (m = 0; ngx_modules[m]; m++) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
409 if (ngx_modules[m]->type != NGX_HTTP_MODULE) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
410 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
411 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
412
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
413 module = ngx_modules[m]->ctx;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
414 mi = ngx_modules[m]->ctx_index;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
415
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
416 if (module->postconfiguration) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
417 if (module->postconfiguration(cf) != NGX_OK) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
418 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
419 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
420 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
421 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
422
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
423 if (ngx_http_variables_init_vars(cf) != NGX_OK) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
424 return NGX_CONF_ERROR;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
425 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
426
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
427 /*
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
428 * http{}'s cf->ctx was needed while the configuration merging
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
429 * and in postconfiguration process
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
430 */
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
431
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
432 *cf = pcf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
433
56
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 52
diff changeset
434
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
435 /*
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
436 * create the lists of ports, addresses and server names
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
437 * to quickly find the server core module configuration at run-time
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
438 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
439
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
440 if (ngx_array_init(&in_ports, cf->temp_pool, 2,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
441 sizeof(ngx_http_conf_in_port_t))
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
442 != NGX_OK)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
443 {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
444 return NGX_CONF_ERROR;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
445 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
446
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
447 /* "server" directives */
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
448
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
449 cscfp = cmcf->servers.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
450 for (s = 0; s < cmcf->servers.nelts; s++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
451
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
452 /* "listen" directives */
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
453
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
454 lscf = cscfp[s]->listen.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
455 for (l = 0; l < cscfp[s]->listen.nelts; l++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
456
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
457 /* AF_INET only */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
458
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
459 in_port = in_ports.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
460 for (p = 0; p < in_ports.nelts; p++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
461
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
462 if (lscf[l].port != in_port[p].port) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
463 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
464 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
465
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
466 /* the port is already in the port list */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
467
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
468 in_addr = in_port[p].addrs.elts;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
469 for (a = 0; a < in_port[p].addrs.nelts; a++) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
470
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
471 if (lscf[l].addr != in_addr[a].addr) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
472 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
473 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
474
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
475 /* the address is already in the address list */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
476
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
477 if (ngx_http_add_names(cf, &in_addr[a], cscfp[s]) != NGX_OK)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
478 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
479 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
480 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
481
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
482 /*
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
483 * check the duplicate "default" server
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
484 * for this address:port
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
485 */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
486
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
487 if (lscf[l].conf.default_server) {
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
488
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
489 if (in_addr[a].default_server) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
490 ngx_log_error(NGX_LOG_ERR, cf->log, 0,
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
491 "the duplicate default server in %V:%d",
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
492 &lscf[l].file_name, lscf[l].line);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
493
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
494 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
495 }
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
496
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
497 in_addr[a].core_srv_conf = cscfp[s];
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
498 in_addr[a].default_server = 1;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
499 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
500
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
501 goto found;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
502 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
503
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
504 /*
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
505 * add the address to the addresses list that
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
506 * bound to this port
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
507 */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
508
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
509 if (ngx_http_add_address(cf, &in_port[p], &lscf[l], cscfp[s])
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
510 != NGX_OK)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
511 {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
512 return NGX_CONF_ERROR;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
513 }
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
514
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
515 goto found;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
516 }
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
517
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
518 /* add the port to the in_port list */
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
519
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
520 in_port = ngx_array_push(&in_ports);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
521 if (in_port == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
522 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
523 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
524
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
525 in_port->port = lscf[l].port;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
526 in_port->addrs.elts = NULL;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
527
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
528 if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s]) != NGX_OK)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
529 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
530 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
531 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
532
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
533 found:
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
534
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
535 continue;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
536 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
537 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
538
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
539
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
540 /* optimize the lists of ports, addresses and server names */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
541
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
542 /* AF_INET only */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
543
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
544 in_port = in_ports.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
545 for (p = 0; p < in_ports.nelts; p++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
546
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
547 ngx_qsort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
548 sizeof(ngx_http_conf_in_addr_t), ngx_http_cmp_conf_in_addrs);
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
549
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
550 /*
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
551 * check whether all name-based servers have the same configuraiton
152
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
552 * as the default server,
158
2d15b82126ed nginx 0.3.26
Igor Sysoev <http://sysoev.ru>
parents: 152
diff changeset
553 * or some servers disable optimizing the server names
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
554 */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
555
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
556 in_addr = in_port[p].addrs.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
557 for (a = 0; a < in_port[p].addrs.nelts; a++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
558
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
559 name = in_addr[a].names.elts;
152
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
560 for (s = 0; s < in_addr[a].names.nelts; s++) {
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
561
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
562 if (in_addr[a].core_srv_conf != name[s].core_srv_conf
162
6be073125f2e nginx 0.3.28
Igor Sysoev <http://sysoev.ru>
parents: 158
diff changeset
563 || name[s].core_srv_conf->optimize_server_names == 0)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
564 {
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
565 goto virtual_names;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
566 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
567 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
568
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
569 /*
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
570 * if all name-based servers have the same configuration
152
396dbbc06dd7 nginx 0.3.23
Igor Sysoev <http://sysoev.ru>
parents: 144
diff changeset
571 * as the default server,
158
2d15b82126ed nginx 0.3.26
Igor Sysoev <http://sysoev.ru>
parents: 152
diff changeset
572 * and no servers disable optimizing the server names
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
573 * then we do not need to check them at run-time at all
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
574 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
575
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
576 in_addr[a].names.nelts = 0;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
577
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
578 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
579
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
580 virtual_names:
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
581
168
3314be145cb9 nginx 0.3.31
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
582 ngx_memzero(&ha, sizeof(ngx_hash_keys_arrays_t));
3314be145cb9 nginx 0.3.31
Igor Sysoev <http://sysoev.ru>
parents: 162
diff changeset
583
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
584 ha.temp_pool = ngx_create_pool(16384, cf->log);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
585 if (ha.temp_pool == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
586 return NGX_CONF_ERROR;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
587 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
588
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
589 ha.pool = cf->pool;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
590
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
591 if (ngx_hash_keys_array_init(&ha, NGX_HASH_LARGE) != NGX_OK) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
592 ngx_destroy_pool(ha.temp_pool);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
593 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
594 }
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
595
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
596 name = in_addr[a].names.elts;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
597 for (s = 0; s < in_addr[a].names.nelts; s++) {
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
598
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
599 ch = name[s].name.data[0];
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
600
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
601 if (ch == '*' || ch == '.') {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
602 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
603 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
604
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
605 rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
606 0);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
607
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
608 if (rc == NGX_ERROR) {
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
609 return NGX_CONF_ERROR;
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
610 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
611
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
612 if (rc == NGX_BUSY) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
613 ngx_log_error(NGX_LOG_WARN, cf->log, 0,
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 170
diff changeset
614 "conflicting server name \"%V\" on %s, ignored",
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 170
diff changeset
615 &name[s].name, in_addr[a].listen_conf->addr);
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
616 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
617 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
618
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
619 for (s = 0; s < in_addr[a].names.nelts; s++) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
620
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
621 ch = name[s].name.data[0];
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
622
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
623 if (ch != '*' && ch != '.') {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
624 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
625 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
626
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
627 rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
628 NGX_HASH_WILDCARD_KEY);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
629
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
630 if (rc == NGX_ERROR) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
631 return NGX_CONF_ERROR;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
632 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
633
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
634 if (rc == NGX_BUSY) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
635 ngx_log_error(NGX_LOG_WARN, cf->log, 0,
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 170
diff changeset
636 "conflicting server name \"%V\" on %s, ignored",
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 170
diff changeset
637 &name[s].name, in_addr[a].listen_conf->addr);
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
638 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
639 }
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
640
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
641 hash.key = ngx_hash_key_lc;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
642 hash.max_size = cmcf->server_names_hash_max_size;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
643 hash.bucket_size = cmcf->server_names_hash_bucket_size;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
644 hash.name = "server_names_hash";
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
645 hash.pool = cf->pool;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
646
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
647 if (ha.keys.nelts) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
648 hash.hash = &in_addr[a].hash;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
649 hash.temp_pool = NULL;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
650
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
651 if (ngx_hash_init(&hash, ha.keys.elts, ha.keys.nelts) != NGX_OK)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
652 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
653 ngx_destroy_pool(ha.temp_pool);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
654 return NGX_CONF_ERROR;
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
655 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
656 }
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
657
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
658 if (ha.dns_wildcards.nelts) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
659
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
660 ngx_qsort(ha.dns_wildcards.elts,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
661 (size_t) ha.dns_wildcards.nelts,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
662 sizeof(ngx_hash_key_t),
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
663 ngx_http_cmp_dns_wildcards);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
664
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
665 hash.hash = NULL;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
666 hash.temp_pool = ha.temp_pool;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
667
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
668 if (ngx_hash_wildcard_init(&hash, ha.dns_wildcards.elts,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
669 ha.dns_wildcards.nelts)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
670 != NGX_OK)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
671 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
672 ngx_destroy_pool(ha.temp_pool);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
673 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
674 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
675
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
676 in_addr[a].dns_wildcards = (ngx_hash_wildcard_t *) hash.hash;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
677 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
678
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
679 ngx_destroy_pool(ha.temp_pool);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
680 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
681
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
682 in_addr = in_port[p].addrs.elts;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
683 last = in_port[p].addrs.nelts;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
684
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
685 /*
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
686 * if there is the binding to the "*:port" then we need to bind()
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
687 * to the "*:port" only and ignore the other bindings
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
688 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
689
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
690 if (in_addr[last - 1].addr == INADDR_ANY) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
691 in_addr[last - 1].bind = 1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
692 bind_all = 0;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
693
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
694 } else {
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
695 bind_all = 1;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
696 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
697
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
698 for (a = 0; a < last; /* void */ ) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
699
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
700 if (!bind_all && !in_addr[a].bind) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
701 a++;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
702 continue;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
703 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
704
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
705 ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
706 in_port[p].port);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
707 if (ls == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
708 return NGX_CONF_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
709 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
710
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
711 ls->addr_ntop = 1;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
712
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
713 ls->handler = ngx_http_init_connection;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
714
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
715 cscf = in_addr[a].core_srv_conf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
716 ls->pool_size = cscf->connection_pool_size;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
717 ls->post_accept_timeout = cscf->client_header_timeout;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
718
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
719 clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index];
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
720
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
721 ls->log = *clcf->err_log;
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
722 ls->log.data = &ls->addr_text;
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
723 ls->log.handler = ngx_accept_log_error;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
724
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
725 #if (NGX_WIN32)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
726 iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
727 if (iocpcf->acceptex_read) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
728 ls->post_accept_buffer_size = cscf->client_header_buffer_size;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
729 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
730 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
731
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
732 ls->backlog = in_addr[a].listen_conf->backlog;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
733 ls->rcvbuf = in_addr[a].listen_conf->rcvbuf;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
734 ls->sndbuf = in_addr[a].listen_conf->sndbuf;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
735
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
736 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
737 ls->accept_filter = in_addr[a].listen_conf->accept_filter;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
738 #endif
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
739
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
740 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
741 ls->deferred_accept = in_addr[a].listen_conf->deferred_accept;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
742 #endif
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 70
diff changeset
743
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
744 hip = ngx_palloc(cf->pool, sizeof(ngx_http_in_port_t));
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
745 if (hip == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
746 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
747 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
748
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
749 hip->port = in_port[p].port;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
750
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
751 hip->port_text.data = ngx_palloc(cf->pool, 7);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
752 if (hip->port_text.data == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
753 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
754 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
755
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
756 ls->servers = hip;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
757
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
758 hip->port_text.len = ngx_sprintf(hip->port_text.data, ":%d",
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
759 hip->port)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
760 - hip->port_text.data;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
761
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
762 in_addr = in_port[p].addrs.elts;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
763
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
764 if (in_addr[a].bind && in_addr[a].addr != INADDR_ANY) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
765 hip->naddrs = 1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
766 done = 0;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
767
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
768 } else if (in_port[p].addrs.nelts > 1
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
769 && in_addr[last - 1].addr == INADDR_ANY)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
770 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
771 hip->naddrs = last;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
772 done = 1;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
773
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
774 } else {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
775 hip->naddrs = 1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
776 done = 0;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
777 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
778
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
779 #if 0
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
780 ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
781 "%ui: %V %d %ui %ui",
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
782 a, &ls->addr_text, in_addr[a].bind,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
783 hip->naddrs, last);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
784 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
785
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
786 hip->addrs = ngx_pcalloc(cf->pool,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
787 hip->naddrs * sizeof(ngx_http_in_addr_t));
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
788 if (hip->addrs == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
789 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
790 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
791
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
792 for (i = 0; i < hip->naddrs; i++) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
793 hip->addrs[i].addr = in_addr[i].addr;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
794 hip->addrs[i].core_srv_conf = in_addr[i].core_srv_conf;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
795
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
796 if (in_addr[i].hash.buckets == NULL
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
797 && (in_addr[i].dns_wildcards == NULL
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
798 || in_addr[i].dns_wildcards->hash.buckets == NULL))
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
799 {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
800 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
801 }
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
802
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
803 vn = ngx_palloc(cf->pool, sizeof(ngx_http_virtual_names_t));
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
804 if (vn == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
805 return NGX_CONF_ERROR;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
806 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
807 hip->addrs[i].virtual_names = vn;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
808
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
809 vn->hash = in_addr[i].hash;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
810 vn->dns_wildcards = in_addr[i].dns_wildcards;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
811 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
812
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
813 if (done) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
814 break;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
815 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
816
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
817 in_addr++;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
818 in_port[p].addrs.elts = in_addr;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
819 last--;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
820
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
821 a = 0;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
822 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
823 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
824
138
8e6d4d96ec4c nginx 0.3.16
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
825 #if 0
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
826 {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
827 u_char address[20];
138
8e6d4d96ec4c nginx 0.3.16
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
828 ngx_uint_t p, a;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
829
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
830 in_port = in_ports.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
831 for (p = 0; p < in_ports.nelts; p++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
832 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
833 "port: %d %p", in_port[p].port, &in_port[p]);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
834 in_addr = in_port[p].addrs.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
835 for (a = 0; a < in_port[p].addrs.nelts; a++) {
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
836 ngx_inet_ntop(AF_INET, &in_addr[a].addr, address, 20);
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
837 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, cf->log, 0,
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
838 "%s:%d %p",
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
839 address, in_port[p].port, in_addr[a].core_srv_conf);
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
840 name = in_addr[a].names.elts;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
841 for (n = 0; n < in_addr[a].names.nelts; n++) {
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
842 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, cf->log, 0,
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
843 "%s:%d %V %p",
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
844 address, in_port[p].port, &name[n].name,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
845 name[n].core_srv_conf);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
846 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
847 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
848 }
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
849 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
850 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
851
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
852 return NGX_CONF_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
853 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
854
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
855
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
856 /*
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
857 * add the server address, the server names and the server core module
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
858 * configurations to the port (in_port)
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
859 */
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
860
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
861 static ngx_int_t
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
862 ngx_http_add_address(ngx_conf_t *cf, ngx_http_conf_in_port_t *in_port,
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
863 ngx_http_listen_t *lscf, ngx_http_core_srv_conf_t *cscf)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
864 {
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
865 ngx_http_conf_in_addr_t *in_addr;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
866
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
867 if (in_port->addrs.elts == NULL) {
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
868 if (ngx_array_init(&in_port->addrs, cf->temp_pool, 4,
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
869 sizeof(ngx_http_conf_in_addr_t)) != NGX_OK)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
870 {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
871 return NGX_ERROR;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
872 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
873 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
874
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
875 in_addr = ngx_array_push(&in_port->addrs);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
876 if (in_addr == NULL) {
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
877 return NGX_ERROR;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
878 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
879
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
880 in_addr->addr = lscf->addr;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
881 in_addr->hash.buckets = NULL;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
882 in_addr->hash.size = 0;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
883 in_addr->dns_wildcards = NULL;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
884 in_addr->names.elts = NULL;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
885 in_addr->core_srv_conf = cscf;
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
886 in_addr->default_server = lscf->conf.default_server;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
887 in_addr->bind = lscf->conf.bind;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
888 in_addr->listen_conf = &lscf->conf;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
889
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
890 #if (NGX_DEBUG)
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
891 {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
892 u_char text[20];
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
893 ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20);
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
894 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, "address: %s:%d",
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
895 text, in_port->port);
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
896 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
897 #endif
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
898
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
899 return ngx_http_add_names(cf, in_addr, cscf);
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
900 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
901
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
902
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
903 /*
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
904 * add the server names and the server core module
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
905 * configurations to the address:port (in_addr)
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
906 */
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
907
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
908 static ngx_int_t
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
909 ngx_http_add_names(ngx_conf_t *cf, ngx_http_conf_in_addr_t *in_addr,
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
910 ngx_http_core_srv_conf_t *cscf)
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
911 {
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
912 ngx_uint_t i, n;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
913 ngx_http_server_name_t *server_names, *name;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
914
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
915 if (in_addr->names.elts == NULL) {
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
916 if (ngx_array_init(&in_addr->names, cf->temp_pool, 4,
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
917 sizeof(ngx_http_server_name_t)) != NGX_OK)
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
918 {
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
919 return NGX_ERROR;
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
920 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
921 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
922
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
923 server_names = cscf->server_names.elts;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
924 for (i = 0; i < cscf->server_names.nelts; i++) {
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
925
26
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
926 for (n = 0; n < server_names[i].name.len; n++) {
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
927 server_names[i].name.data[n] =
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
928 ngx_tolower(server_names[i].name.data[n]);
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
929 }
45fe5b98a9de nginx 0.1.13
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
930
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
931 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
932 "name: %V", &server_names[i].name);
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
933
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
934
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
935 name = ngx_array_push(&in_addr->names);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
936 if (name == NULL) {
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
937 return NGX_ERROR;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
938 }
70
8ad297c88dcb nginx 0.1.35
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
939 server_names = cscf->server_names.elts;
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
940
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
941 *name = server_names[i];
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
942 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
943
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
944 return NGX_OK;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
945 }
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
946
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
947
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
948 static char *
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
949 ngx_http_merge_locations(ngx_conf_t *cf, ngx_array_t *locations,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents: 34
diff changeset
950 void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
951 {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
952 char *rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
953 ngx_uint_t i;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
954 ngx_http_core_loc_conf_t **clcfp;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
955
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
956 clcfp = locations->elts;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
957
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
958 for (i = 0; i < locations->nelts; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
959 rv = module->merge_loc_conf(cf, loc_conf[ctx_index],
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
960 clcfp[i]->loc_conf[ctx_index]);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
961 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
962 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
963 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
964
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
965 rv = ngx_http_merge_locations(cf, &clcfp[i]->locations,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
966 clcfp[i]->loc_conf, module, ctx_index);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
967 if (rv != NGX_CONF_OK) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
968 return rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
969 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
970 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
971
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
972 return NGX_CONF_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
973 }
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
974
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
975
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
976 static int ngx_libc_cdecl
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
977 ngx_http_cmp_conf_in_addrs(const void *one, const void *two)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
978 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
979 ngx_http_conf_in_addr_t *first, *second;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
980
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
981 first = (ngx_http_conf_in_addr_t *) one;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
982 second = (ngx_http_conf_in_addr_t *) two;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
983
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
984 if (first->addr == INADDR_ANY) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
985 /* the INADDR_ANY must be the last resort, shift it to the end */
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
986 return 1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
987 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
988
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
989 if (first->bind && !second->bind) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
990 /* shift explicit bind()ed addresses to the start */
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
991 return -1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
992 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
993
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
994 if (!first->bind && second->bind) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
995 /* shift explicit bind()ed addresses to the start */
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
996 return 1;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
997 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
998
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
999 /* do not sort by default */
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1000
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1001 return 0;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1002 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1003
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1004
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1005 static int ngx_libc_cdecl
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1006 ngx_http_cmp_dns_wildcards(const void *one, const void *two)
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1007 {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1008 ngx_hash_key_t *first, *second;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1009
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1010 first = (ngx_hash_key_t *) one;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1011 second = (ngx_hash_key_t *) two;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1012
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1013 return ngx_strcmp(first->key.data, second->key.data);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1014 }