Mercurial > hg > nginx-quic
annotate src/http/ngx_http.c @ 1908:f2953601ed3c
fix memory leak in long-lived non buffered connections
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 03 Mar 2008 10:42:00 +0000 |
parents | e584e946e198 |
children | 8c64532e4875 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
5 |
2
ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
7 #include <ngx_config.h> |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
8 #include <ngx_core.h> |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
9 #include <ngx_event.h> |
2
ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
12 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
13 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
455 | 14 static ngx_int_t ngx_http_add_address(ngx_conf_t *cf, |
593 | 15 ngx_http_conf_in_port_t *in_port, ngx_http_listen_t *lscf, |
499 | 16 ngx_http_core_srv_conf_t *cscf); |
455 | 17 static ngx_int_t ngx_http_add_names(ngx_conf_t *cf, |
593 | 18 ngx_http_conf_in_addr_t *in_addr, ngx_http_core_srv_conf_t *cscf); |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
19 static char *ngx_http_merge_locations(ngx_conf_t *cf, |
499 | 20 ngx_array_t *locations, void **loc_conf, ngx_http_module_t *module, |
21 ngx_uint_t ctx_index); | |
1209
c6c33f81fd79
use stable search where it is required
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
22 static int ngx_http_cmp_conf_in_addrs(const void *one, const void *two); |
593 | 23 static int ngx_libc_cdecl ngx_http_cmp_dns_wildcards(const void *one, |
24 const void *two); | |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
25 |
593 | 26 ngx_uint_t ngx_http_max_module; |
27 | |
28 ngx_uint_t ngx_http_total_requests; | |
29 uint64_t ngx_http_total_sent; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
30 |
45
f1ee46c036a4
nginx-0.0.1-2003-01-10-09:09:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
31 |
356
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
32 ngx_int_t (*ngx_http_top_header_filter) (ngx_http_request_t *r); |
2e3cbc1bbe3c
nginx-0.0.7-2004-06-16-19:32:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
33 ngx_int_t (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
34 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
35 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
36 static ngx_command_t ngx_http_commands[] = { |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
37 |
499 | 38 { ngx_string("http"), |
39 NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, | |
40 ngx_http_block, | |
41 0, | |
42 0, | |
43 NULL }, | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
44 |
499 | 45 ngx_null_command |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
46 }; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
47 |
577 | 48 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
49 static ngx_core_module_t ngx_http_module_ctx = { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
50 ngx_string("http"), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
51 NULL, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
52 NULL |
577 | 53 }; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
54 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
55 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
56 ngx_module_t ngx_http_module = { |
509 | 57 NGX_MODULE_V1, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
291
diff
changeset
|
58 &ngx_http_module_ctx, /* module context */ |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
59 ngx_http_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
60 NGX_CORE_MODULE, /* module type */ |
541 | 61 NULL, /* init master */ |
116
571bcbff82c5
nginx-0.0.1-2003-07-11-08:50:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
62 NULL, /* init module */ |
541 | 63 NULL, /* init process */ |
64 NULL, /* init thread */ | |
65 NULL, /* exit thread */ | |
66 NULL, /* exit process */ | |
67 NULL, /* exit master */ | |
68 NGX_MODULE_V1_PADDING | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
69 }; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
70 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
71 |
499 | 72 static char * |
73 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
74 { |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
75 char *rv; |
681 | 76 ngx_int_t rc, j; |
77 ngx_uint_t mi, m, s, l, p, a, i, n; | |
78 ngx_uint_t find_config_index, use_rewrite, use_access; | |
593 | 79 ngx_uint_t last, bind_all, done; |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
80 ngx_conf_t pcf; |
649 | 81 ngx_array_t headers_in, in_ports; |
82 ngx_hash_key_t *hk; | |
593 | 83 ngx_hash_init_t hash; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
84 ngx_listening_t *ls; |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
85 ngx_http_listen_t *lscf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
86 ngx_http_module_t *module; |
649 | 87 ngx_http_header_t *header; |
593 | 88 ngx_http_in_port_t *hip; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
89 ngx_http_handler_pt *h; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
90 ngx_http_conf_ctx_t *ctx; |
593 | 91 ngx_http_conf_in_port_t *in_port; |
92 ngx_http_conf_in_addr_t *in_addr; | |
93 ngx_hash_keys_arrays_t ha; | |
94 ngx_http_server_name_t *name; | |
681 | 95 ngx_http_phase_handler_t *ph; |
593 | 96 ngx_http_virtual_names_t *vn; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
97 ngx_http_core_srv_conf_t **cscfp, *cscf; |
401
b32ca005e025
nginx-0.0.9-2004-07-26-22:31:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
98 ngx_http_core_loc_conf_t *clcf; |
681 | 99 ngx_http_phase_handler_pt checker; |
216
f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
213
diff
changeset
|
100 ngx_http_core_main_conf_t *cmcf; |
1387 | 101 #if (NGX_PCRE) |
102 ngx_uint_t regex; | |
103 #endif | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
104 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
105 /* the main http context */ |
477 | 106 |
501 | 107 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)); |
108 if (ctx == NULL) { | |
485 | 109 return NGX_CONF_ERROR; |
110 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
111 |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
112 *(ngx_http_conf_ctx_t **) conf = ctx; |
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
113 |
485 | 114 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
115 /* count the number of the http modules and set up their indices */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
116 |
71
59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
69
diff
changeset
|
117 ngx_http_max_module = 0; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
118 for (m = 0; ngx_modules[m]; m++) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
119 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
120 continue; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
121 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
122 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
123 ngx_modules[m]->ctx_index = ngx_http_max_module++; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
124 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
125 |
477 | 126 |
485 | 127 /* the http main_conf context, it is the same in the all http contexts */ |
90
37530da31268
nginx-0.0.1-2003-05-16-19:27:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
128 |
485 | 129 ctx->main_conf = ngx_pcalloc(cf->pool, |
130 sizeof(void *) * ngx_http_max_module); | |
131 if (ctx->main_conf == NULL) { | |
132 return NGX_CONF_ERROR; | |
133 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
134 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
135 |
485 | 136 /* |
137 * the http null srv_conf context, it is used to merge | |
138 * the server{}s' srv_conf's | |
139 */ | |
140 | |
141 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); | |
142 if (ctx->srv_conf == NULL) { | |
143 return NGX_CONF_ERROR; | |
144 } | |
145 | |
146 | |
147 /* | |
148 * the http null loc_conf context, it is used to merge | |
149 * the server{}s' loc_conf's | |
150 */ | |
151 | |
152 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); | |
153 if (ctx->loc_conf == NULL) { | |
154 return NGX_CONF_ERROR; | |
155 } | |
156 | |
157 | |
158 /* | |
159 * create the main_conf's, the null srv_conf's, and the null loc_conf's | |
160 * of the all http modules | |
161 */ | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
162 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
163 for (m = 0; ngx_modules[m]; m++) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
164 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
165 continue; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
166 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
167 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
168 module = ngx_modules[m]->ctx; |
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
169 mi = ngx_modules[m]->ctx_index; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
170 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
171 if (module->create_main_conf) { |
501 | 172 ctx->main_conf[mi] = module->create_main_conf(cf); |
173 if (ctx->main_conf[mi] == NULL) { | |
485 | 174 return NGX_CONF_ERROR; |
175 } | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
176 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
177 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
178 if (module->create_srv_conf) { |
501 | 179 ctx->srv_conf[mi] = module->create_srv_conf(cf); |
180 if (ctx->srv_conf[mi] == NULL) { | |
485 | 181 return NGX_CONF_ERROR; |
182 } | |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
183 } |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
184 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
185 if (module->create_loc_conf) { |
501 | 186 ctx->loc_conf[mi] = module->create_loc_conf(cf); |
187 if (ctx->loc_conf[mi] == NULL) { | |
485 | 188 return NGX_CONF_ERROR; |
189 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
190 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
191 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
192 |
509 | 193 pcf = *cf; |
194 cf->ctx = ctx; | |
195 | |
196 for (m = 0; ngx_modules[m]; m++) { | |
197 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
198 continue; | |
199 } | |
200 | |
201 module = ngx_modules[m]->ctx; | |
202 mi = ngx_modules[m]->ctx_index; | |
203 | |
204 if (module->preconfiguration) { | |
205 if (module->preconfiguration(cf) != NGX_OK) { | |
206 return NGX_CONF_ERROR; | |
207 } | |
208 } | |
209 } | |
485 | 210 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
211 /* parse inside the http{} block */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
212 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
213 cf->module_type = NGX_HTTP_MODULE; |
88
674d333f4296
nginx-0.0.1-2003-05-14-21:13:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
81
diff
changeset
|
214 cf->cmd_type = NGX_HTTP_MAIN_CONF; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
215 rv = ngx_conf_parse(cf, NULL); |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
216 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
217 if (rv != NGX_CONF_OK) { |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
218 *cf = pcf; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
219 return rv; |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
220 } |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
221 |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
222 /* |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
223 * init http{} main_conf's, merge the server{}s' srv_conf's |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
224 * and its location{}s' loc_conf's |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
225 */ |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
226 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
227 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
228 cscfp = cmcf->servers.elts; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
229 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
230 for (m = 0; ngx_modules[m]; m++) { |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
231 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
232 continue; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
233 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
234 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
235 module = ngx_modules[m]->ctx; |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
236 mi = ngx_modules[m]->ctx_index; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
237 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
238 /* init http{} main_conf's */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
239 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
240 if (module->init_main_conf) { |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
241 rv = module->init_main_conf(cf, ctx->main_conf[mi]); |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
242 if (rv != NGX_CONF_OK) { |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
243 *cf = pcf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
244 return rv; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
245 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
246 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
247 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
248 for (s = 0; s < cmcf->servers.nelts; s++) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
249 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
250 /* merge the server{}s' srv_conf's */ |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
251 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
252 if (module->merge_srv_conf) { |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
253 rv = module->merge_srv_conf(cf, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
254 ctx->srv_conf[mi], |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
255 cscfp[s]->ctx->srv_conf[mi]); |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
256 if (rv != NGX_CONF_OK) { |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
257 *cf = pcf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
258 return rv; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
259 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
260 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
261 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
262 if (module->merge_loc_conf) { |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
263 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
264 /* merge the server{}'s loc_conf */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
265 |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
266 rv = module->merge_loc_conf(cf, |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
267 ctx->loc_conf[mi], |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
268 cscfp[s]->ctx->loc_conf[mi]); |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
269 if (rv != NGX_CONF_OK) { |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
270 *cf = pcf; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
271 return rv; |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
272 } |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
273 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
274 /* merge the locations{}' loc_conf's */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
275 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
276 rv = ngx_http_merge_locations(cf, &cscfp[s]->locations, |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
277 cscfp[s]->ctx->loc_conf, |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
278 module, mi); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
279 if (rv != NGX_CONF_OK) { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
280 *cf = pcf; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
281 return rv; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
282 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
283 } |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
284 } |
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
285 } |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
286 |
485 | 287 |
144
ef8c87afcfc5
nginx-0.0.1-2003-10-12-20:49:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
288 /* init lists of the handlers */ |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
289 |
573 | 290 if (ngx_array_init(&cmcf->phases[NGX_HTTP_POST_READ_PHASE].handlers, |
291 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
292 != NGX_OK) | |
485 | 293 { |
294 return NGX_CONF_ERROR; | |
295 } | |
296 | |
573 | 297 |
298 if (ngx_array_init(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers, | |
299 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
300 != NGX_OK) | |
301 { | |
302 return NGX_CONF_ERROR; | |
303 } | |
304 | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
305 |
573 | 306 if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, |
307 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
308 != NGX_OK) | |
309 { | |
310 return NGX_CONF_ERROR; | |
311 } | |
312 | |
313 | |
581 | 314 if (ngx_array_init(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers, |
315 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
316 != NGX_OK) | |
317 { | |
318 return NGX_CONF_ERROR; | |
319 } | |
320 | |
321 | |
485 | 322 if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers, |
581 | 323 cf->pool, 2, sizeof(ngx_http_handler_pt)) |
573 | 324 != NGX_OK) |
485 | 325 { |
326 return NGX_CONF_ERROR; | |
327 } | |
328 | |
368
15c84a40e87d
nginx-0.0.7-2004-06-24-20:07:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
329 |
485 | 330 if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers, |
573 | 331 cf->pool, 4, sizeof(ngx_http_handler_pt)) |
332 != NGX_OK) | |
485 | 333 { |
334 return NGX_CONF_ERROR; | |
335 } | |
336 | |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
337 |
581 | 338 if (ngx_array_init(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers, |
339 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
340 != NGX_OK) | |
341 { | |
342 return NGX_CONF_ERROR; | |
343 } | |
344 | |
345 | |
649 | 346 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t)) |
507 | 347 != NGX_OK) |
348 { | |
349 return NGX_CONF_ERROR; | |
350 } | |
351 | |
649 | 352 for (header = ngx_http_headers_in; header->name.len; header++) { |
353 hk = ngx_array_push(&headers_in); | |
354 if (hk == NULL) { | |
355 return NGX_CONF_ERROR; | |
356 } | |
357 | |
358 hk->key = header->name; | |
359 hk->key_hash = ngx_hash_key_lc(header->name.data, header->name.len); | |
360 hk->value = header; | |
361 } | |
362 | |
363 hash.hash = &cmcf->headers_in_hash; | |
364 hash.key = ngx_hash_key_lc; | |
365 hash.max_size = 512; | |
751
bae59a740c40
align hash bucket size to cache line
Igor Sysoev <igor@sysoev.ru>
parents:
750
diff
changeset
|
366 hash.bucket_size = ngx_align(64, ngx_cacheline_size); |
649 | 367 hash.name = "headers_in_hash"; |
368 hash.pool = cf->pool; | |
369 hash.temp_pool = NULL; | |
370 | |
371 if (ngx_hash_init(&hash, headers_in.elts, headers_in.nelts) != NGX_OK) { | |
372 return NGX_CONF_ERROR; | |
373 } | |
374 | |
509 | 375 |
376 for (m = 0; ngx_modules[m]; m++) { | |
377 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
378 continue; | |
379 } | |
380 | |
381 module = ngx_modules[m]->ctx; | |
382 mi = ngx_modules[m]->ctx_index; | |
383 | |
384 if (module->postconfiguration) { | |
385 if (module->postconfiguration(cf) != NGX_OK) { | |
386 return NGX_CONF_ERROR; | |
387 } | |
388 } | |
389 } | |
390 | |
573 | 391 if (ngx_http_variables_init_vars(cf) != NGX_OK) { |
392 return NGX_CONF_ERROR; | |
393 } | |
509 | 394 |
395 /* | |
396 * http{}'s cf->ctx was needed while the configuration merging | |
397 * and in postconfiguration process | |
398 */ | |
399 | |
400 *cf = pcf; | |
401 | |
507 | 402 |
681 | 403 cmcf->phase_engine.server_rewrite_index = (ngx_uint_t) -1; |
1353 | 404 cmcf->phase_engine.location_rewrite_index = (ngx_uint_t) -1; |
681 | 405 find_config_index = 0; |
406 use_rewrite = cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers.nelts ? 1 : 0; | |
407 use_access = cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.nelts ? 1 : 0; | |
408 | |
409 n = use_rewrite + use_access + 1; /* find config phase */ | |
410 | |
411 for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) { | |
412 n += cmcf->phases[i].handlers.nelts; | |
413 } | |
414 | |
415 ph = ngx_pcalloc(cf->pool, | |
416 n * sizeof(ngx_http_phase_handler_t) + sizeof(void *)); | |
417 if (ph == NULL) { | |
418 return NGX_CONF_ERROR; | |
419 } | |
420 | |
421 cmcf->phase_engine.handlers = ph; | |
422 n = 0; | |
423 | |
424 for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) { | |
425 h = cmcf->phases[i].handlers.elts; | |
426 | |
427 switch (i) { | |
428 | |
429 case NGX_HTTP_SERVER_REWRITE_PHASE: | |
430 if (cmcf->phase_engine.server_rewrite_index == (ngx_uint_t) -1) { | |
431 cmcf->phase_engine.server_rewrite_index = n; | |
432 } | |
433 checker = ngx_http_core_generic_phase; | |
434 | |
435 break; | |
436 | |
437 case NGX_HTTP_FIND_CONFIG_PHASE: | |
438 find_config_index = n; | |
439 | |
440 ph->checker = ngx_http_core_find_config_phase; | |
441 n++; | |
442 ph++; | |
443 | |
444 continue; | |
445 | |
1353 | 446 case NGX_HTTP_REWRITE_PHASE: |
447 if (cmcf->phase_engine.location_rewrite_index == (ngx_uint_t) -1) { | |
448 cmcf->phase_engine.location_rewrite_index = n; | |
449 } | |
450 checker = ngx_http_core_generic_phase; | |
451 | |
452 break; | |
453 | |
681 | 454 case NGX_HTTP_POST_REWRITE_PHASE: |
455 if (use_rewrite) { | |
456 ph->checker = ngx_http_core_post_rewrite_phase; | |
457 ph->next = find_config_index; | |
458 n++; | |
459 ph++; | |
460 } | |
461 | |
462 continue; | |
463 | |
464 case NGX_HTTP_ACCESS_PHASE: | |
465 checker = ngx_http_core_access_phase; | |
466 n++; | |
467 break; | |
468 | |
469 case NGX_HTTP_POST_ACCESS_PHASE: | |
470 if (use_access) { | |
471 ph->checker = ngx_http_core_post_access_phase; | |
472 ph->next = n; | |
473 ph++; | |
474 } | |
475 | |
476 continue; | |
477 | |
478 case NGX_HTTP_CONTENT_PHASE: | |
479 checker = ngx_http_core_content_phase; | |
480 break; | |
481 | |
482 default: | |
483 checker = ngx_http_core_generic_phase; | |
484 } | |
485 | |
486 n += cmcf->phases[i].handlers.nelts; | |
487 | |
488 for (j = cmcf->phases[i].handlers.nelts - 1; j >=0; j--) { | |
489 ph->checker = checker; | |
490 ph->handler = h[j]; | |
491 ph->next = n; | |
492 ph++; | |
493 } | |
494 } | |
495 | |
496 | |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
497 /* |
455 | 498 * create the lists of ports, addresses and server names |
499 * to quickly find the server core module configuration at run-time | |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
500 */ |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
501 |
593 | 502 if (ngx_array_init(&in_ports, cf->temp_pool, 2, |
503 sizeof(ngx_http_conf_in_port_t)) | |
501 | 504 != NGX_OK) |
455 | 505 { |
506 return NGX_CONF_ERROR; | |
507 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
508 |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
509 /* "server" directives */ |
455 | 510 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
511 cscfp = cmcf->servers.elts; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
512 for (s = 0; s < cmcf->servers.nelts; s++) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
513 |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
514 /* "listen" directives */ |
455 | 515 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
516 lscf = cscfp[s]->listen.elts; |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
517 for (l = 0; l < cscfp[s]->listen.nelts; l++) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
518 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
519 /* AF_INET only */ |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
520 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
521 in_port = in_ports.elts; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
522 for (p = 0; p < in_ports.nelts; p++) { |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
523 |
593 | 524 if (lscf[l].port != in_port[p].port) { |
525 continue; | |
526 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
527 |
593 | 528 /* the port is already in the port list */ |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
529 |
593 | 530 in_addr = in_port[p].addrs.elts; |
531 for (a = 0; a < in_port[p].addrs.nelts; a++) { | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
532 |
593 | 533 if (lscf[l].addr != in_addr[a].addr) { |
534 continue; | |
535 } | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
536 |
593 | 537 /* the address is already in the address list */ |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
538 |
593 | 539 if (ngx_http_add_names(cf, &in_addr[a], cscfp[s]) != NGX_OK) |
540 { | |
541 return NGX_CONF_ERROR; | |
542 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
543 |
593 | 544 /* |
545 * check the duplicate "default" server | |
546 * for this address:port | |
547 */ | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
548 |
593 | 549 if (lscf[l].conf.default_server) { |
455 | 550 |
593 | 551 if (in_addr[a].default_server) { |
552 ngx_log_error(NGX_LOG_ERR, cf->log, 0, | |
1489
56f1ea5baabb
u_char* is enough to keep file name
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
553 "the duplicate default server in %s:%ui", |
56f1ea5baabb
u_char* is enough to keep file name
Igor Sysoev <igor@sysoev.ru>
parents:
1387
diff
changeset
|
554 &lscf[l].file_name, lscf[l].line); |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
555 |
593 | 556 return NGX_CONF_ERROR; |
557 } | |
455 | 558 |
593 | 559 in_addr[a].core_srv_conf = cscfp[s]; |
560 in_addr[a].default_server = 1; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
561 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
562 |
593 | 563 goto found; |
455 | 564 } |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
565 |
593 | 566 /* |
567 * add the address to the addresses list that | |
568 * bound to this port | |
569 */ | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
570 |
593 | 571 if (ngx_http_add_address(cf, &in_port[p], &lscf[l], cscfp[s]) |
501 | 572 != NGX_OK) |
455 | 573 { |
574 return NGX_CONF_ERROR; | |
575 } | |
593 | 576 |
577 goto found; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
578 } |
593 | 579 |
580 /* add the port to the in_port list */ | |
581 | |
582 in_port = ngx_array_push(&in_ports); | |
583 if (in_port == NULL) { | |
584 return NGX_CONF_ERROR; | |
585 } | |
586 | |
587 in_port->port = lscf[l].port; | |
588 in_port->addrs.elts = NULL; | |
589 | |
590 if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s]) != NGX_OK) | |
591 { | |
592 return NGX_CONF_ERROR; | |
593 } | |
594 | |
595 found: | |
596 | |
597 continue; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
598 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
599 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
600 |
455 | 601 |
602 /* optimize the lists of ports, addresses and server names */ | |
54
27b628ef907e
nginx-0.0.1-2003-01-28-18:56:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
603 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
604 /* AF_INET only */ |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
605 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
606 in_port = in_ports.elts; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
607 for (p = 0; p < in_ports.nelts; p++) { |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
608 |
1209
c6c33f81fd79
use stable search where it is required
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
609 ngx_sort(in_port[p].addrs.elts, (size_t) in_port[p].addrs.nelts, |
c6c33f81fd79
use stable search where it is required
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
610 sizeof(ngx_http_conf_in_addr_t), ngx_http_cmp_conf_in_addrs); |
523 | 611 |
455 | 612 /* |
613 * check whether all name-based servers have the same configuraiton | |
603 | 614 * as the default server, |
609 | 615 * or some servers disable optimizing the server names |
455 | 616 */ |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
617 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
618 in_addr = in_port[p].addrs.elts; |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
619 for (a = 0; a < in_port[p].addrs.nelts; a++) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
620 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
621 name = in_addr[a].names.elts; |
603 | 622 for (s = 0; s < in_addr[a].names.nelts; s++) { |
623 | |
624 if (in_addr[a].core_srv_conf != name[s].core_srv_conf | |
613 | 625 || name[s].core_srv_conf->optimize_server_names == 0) |
455 | 626 { |
593 | 627 goto virtual_names; |
477 | 628 } |
629 } | |
630 | |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
631 /* |
455 | 632 * if all name-based servers have the same configuration |
603 | 633 * as the default server, |
609 | 634 * and no servers disable optimizing the server names |
455 | 635 * then we do not need to check them at run-time at all |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
636 */ |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
637 |
593 | 638 in_addr[a].names.nelts = 0; |
639 | |
640 continue; | |
641 | |
642 virtual_names: | |
643 | |
619 | 644 ngx_memzero(&ha, sizeof(ngx_hash_keys_arrays_t)); |
645 | |
593 | 646 ha.temp_pool = ngx_create_pool(16384, cf->log); |
647 if (ha.temp_pool == NULL) { | |
648 return NGX_CONF_ERROR; | |
477 | 649 } |
650 | |
593 | 651 ha.pool = cf->pool; |
477 | 652 |
593 | 653 if (ngx_hash_keys_array_init(&ha, NGX_HASH_LARGE) != NGX_OK) { |
654 ngx_destroy_pool(ha.temp_pool); | |
655 return NGX_CONF_ERROR; | |
656 } | |
477 | 657 |
1387 | 658 #if (NGX_PCRE) |
659 regex = 0; | |
660 #endif | |
661 | |
593 | 662 name = in_addr[a].names.elts; |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
663 |
593 | 664 for (s = 0; s < in_addr[a].names.nelts; s++) { |
477 | 665 |
1387 | 666 #if (NGX_PCRE) |
667 if (name[s].regex) { | |
668 regex++; | |
669 continue; | |
670 } | |
671 #endif | |
672 | |
593 | 673 rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf, |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
674 NGX_HASH_WILDCARD_KEY); |
593 | 675 |
676 if (rc == NGX_ERROR) { | |
477 | 677 return NGX_CONF_ERROR; |
678 } | |
679 | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
680 if (rc == NGX_DECLINED) { |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
681 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
682 "invalid server name or wildcard \"%V\" on %s", |
631 | 683 &name[s].name, in_addr[a].listen_conf->addr); |
593 | 684 return NGX_CONF_ERROR; |
477 | 685 } |
686 | |
593 | 687 if (rc == NGX_BUSY) { |
688 ngx_log_error(NGX_LOG_WARN, cf->log, 0, | |
631 | 689 "conflicting server name \"%V\" on %s, ignored", |
690 &name[s].name, in_addr[a].listen_conf->addr); | |
593 | 691 } |
692 } | |
477 | 693 |
593 | 694 hash.key = ngx_hash_key_lc; |
695 hash.max_size = cmcf->server_names_hash_max_size; | |
696 hash.bucket_size = cmcf->server_names_hash_bucket_size; | |
697 hash.name = "server_names_hash"; | |
698 hash.pool = cf->pool; | |
477 | 699 |
593 | 700 if (ha.keys.nelts) { |
701 hash.hash = &in_addr[a].hash; | |
702 hash.temp_pool = NULL; | |
703 | |
704 if (ngx_hash_init(&hash, ha.keys.elts, ha.keys.nelts) != NGX_OK) | |
705 { | |
706 ngx_destroy_pool(ha.temp_pool); | |
707 return NGX_CONF_ERROR; | |
477 | 708 } |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
709 } |
593 | 710 |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
711 if (ha.dns_wc_head.nelts) { |
593 | 712 |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
713 ngx_qsort(ha.dns_wc_head.elts, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
714 (size_t) ha.dns_wc_head.nelts, |
593 | 715 sizeof(ngx_hash_key_t), |
716 ngx_http_cmp_dns_wildcards); | |
717 | |
718 hash.hash = NULL; | |
719 hash.temp_pool = ha.temp_pool; | |
720 | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
721 if (ngx_hash_wildcard_init(&hash, ha.dns_wc_head.elts, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
722 ha.dns_wc_head.nelts) |
593 | 723 != NGX_OK) |
724 { | |
725 ngx_destroy_pool(ha.temp_pool); | |
726 return NGX_CONF_ERROR; | |
727 } | |
728 | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
729 in_addr[a].wc_head = (ngx_hash_wildcard_t *) hash.hash; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
730 } |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
731 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
732 if (ha.dns_wc_tail.nelts) { |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
733 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
734 ngx_qsort(ha.dns_wc_tail.elts, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
735 (size_t) ha.dns_wc_tail.nelts, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
736 sizeof(ngx_hash_key_t), |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
737 ngx_http_cmp_dns_wildcards); |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
738 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
739 hash.hash = NULL; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
740 hash.temp_pool = ha.temp_pool; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
741 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
742 if (ngx_hash_wildcard_init(&hash, ha.dns_wc_tail.elts, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
743 ha.dns_wc_tail.nelts) |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
744 != NGX_OK) |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
745 { |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
746 ngx_destroy_pool(ha.temp_pool); |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
747 return NGX_CONF_ERROR; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
748 } |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
749 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
750 in_addr[a].wc_tail = (ngx_hash_wildcard_t *) hash.hash; |
593 | 751 } |
752 | |
753 ngx_destroy_pool(ha.temp_pool); | |
1387 | 754 |
755 #if (NGX_PCRE) | |
756 | |
757 if (regex == 0) { | |
758 continue; | |
759 } | |
760 | |
761 in_addr[a].nregex = regex; | |
762 in_addr[a].regex = ngx_palloc(cf->pool, | |
763 regex * sizeof(ngx_http_server_name_t)); | |
764 | |
765 if (in_addr[a].regex == NULL) { | |
766 return NGX_CONF_ERROR; | |
767 } | |
768 | |
769 for (i = 0, s = 0; s < in_addr[a].names.nelts; s++) { | |
770 if (name[s].regex) { | |
771 in_addr[a].regex[i++] = name[s]; | |
772 } | |
773 } | |
774 #endif | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
775 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
776 |
593 | 777 in_addr = in_port[p].addrs.elts; |
778 last = in_port[p].addrs.nelts; | |
779 | |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
780 /* |
477 | 781 * if there is the binding to the "*:port" then we need to bind() |
782 * to the "*:port" only and ignore the other bindings | |
238
674f85a4d00f
nginx-0.0.1-2004-01-23-12:26:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
236
diff
changeset
|
783 */ |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
784 |
593 | 785 if (in_addr[last - 1].addr == INADDR_ANY) { |
786 in_addr[last - 1].bind = 1; | |
787 bind_all = 0; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
788 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
789 } else { |
593 | 790 bind_all = 1; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
791 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
792 |
593 | 793 for (a = 0; a < last; /* void */ ) { |
794 | |
795 if (!bind_all && !in_addr[a].bind) { | |
796 a++; | |
797 continue; | |
798 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
799 |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
800 ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr, |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
801 in_port[p].port); |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
802 if (ls == NULL) { |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
803 return NGX_CONF_ERROR; |
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
804 } |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
805 |
419
47709bff4468
nginx-0.0.10-2004-09-09-19:40:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
806 ls->addr_ntop = 1; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
807 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
808 ls->handler = ngx_http_init_connection; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
809 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
810 cscf = in_addr[a].core_srv_conf; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
811 ls->pool_size = cscf->connection_pool_size; |
523 | 812 ls->post_accept_timeout = cscf->client_header_timeout; |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
813 |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
814 clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index]; |
543 | 815 |
816 ls->log = *clcf->err_log; | |
817 ls->log.data = &ls->addr_text; | |
818 ls->log.handler = ngx_accept_log_error; | |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
819 |
461 | 820 #if (NGX_WIN32) |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1489
diff
changeset
|
821 { |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1489
diff
changeset
|
822 ngx_iocp_conf_t *iocpcf; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1489
diff
changeset
|
823 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
824 iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module); |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
825 if (iocpcf->acceptex_read) { |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
826 ls->post_accept_buffer_size = cscf->client_header_buffer_size; |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
827 } |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1489
diff
changeset
|
828 } |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
829 #endif |
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
830 |
593 | 831 ls->backlog = in_addr[a].listen_conf->backlog; |
832 ls->rcvbuf = in_addr[a].listen_conf->rcvbuf; | |
833 ls->sndbuf = in_addr[a].listen_conf->sndbuf; | |
523 | 834 |
835 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
593 | 836 ls->accept_filter = in_addr[a].listen_conf->accept_filter; |
523 | 837 #endif |
838 | |
839 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
593 | 840 ls->deferred_accept = in_addr[a].listen_conf->deferred_accept; |
523 | 841 #endif |
842 | |
593 | 843 hip = ngx_palloc(cf->pool, sizeof(ngx_http_in_port_t)); |
844 if (hip == NULL) { | |
845 return NGX_CONF_ERROR; | |
846 } | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
847 |
593 | 848 hip->port = in_port[p].port; |
849 | |
850 hip->port_text.data = ngx_palloc(cf->pool, 7); | |
851 if (hip->port_text.data == NULL) { | |
852 return NGX_CONF_ERROR; | |
853 } | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
854 |
593 | 855 ls->servers = hip; |
856 | |
857 hip->port_text.len = ngx_sprintf(hip->port_text.data, ":%d", | |
858 hip->port) | |
859 - hip->port_text.data; | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
860 |
593 | 861 in_addr = in_port[p].addrs.elts; |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
862 |
593 | 863 if (in_addr[a].bind && in_addr[a].addr != INADDR_ANY) { |
864 hip->naddrs = 1; | |
865 done = 0; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
866 |
593 | 867 } else if (in_port[p].addrs.nelts > 1 |
868 && in_addr[last - 1].addr == INADDR_ANY) | |
869 { | |
870 hip->naddrs = last; | |
871 done = 1; | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
872 |
593 | 873 } else { |
874 hip->naddrs = 1; | |
875 done = 0; | |
876 } | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
877 |
593 | 878 #if 0 |
879 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, | |
880 "%ui: %V %d %ui %ui", | |
881 a, &ls->addr_text, in_addr[a].bind, | |
882 hip->naddrs, last); | |
883 #endif | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
884 |
593 | 885 hip->addrs = ngx_pcalloc(cf->pool, |
886 hip->naddrs * sizeof(ngx_http_in_addr_t)); | |
887 if (hip->addrs == NULL) { | |
888 return NGX_CONF_ERROR; | |
889 } | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
890 |
593 | 891 for (i = 0; i < hip->naddrs; i++) { |
892 hip->addrs[i].addr = in_addr[i].addr; | |
893 hip->addrs[i].core_srv_conf = in_addr[i].core_srv_conf; | |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
894 |
593 | 895 if (in_addr[i].hash.buckets == NULL |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
896 && (in_addr[i].wc_head == NULL |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
897 || in_addr[i].wc_head->hash.buckets == NULL) |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
898 && (in_addr[i].wc_head == NULL |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
899 || in_addr[i].wc_head->hash.buckets == NULL)) |
593 | 900 { |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
901 continue; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
902 } |
593 | 903 |
904 vn = ngx_palloc(cf->pool, sizeof(ngx_http_virtual_names_t)); | |
905 if (vn == NULL) { | |
906 return NGX_CONF_ERROR; | |
907 } | |
908 hip->addrs[i].virtual_names = vn; | |
909 | |
1387 | 910 vn->names.hash = in_addr[i].hash; |
911 vn->names.wc_head = in_addr[i].wc_head; | |
912 vn->names.wc_tail = in_addr[i].wc_tail; | |
913 #if (NGX_PCRE) | |
914 vn->nregex = in_addr[i].nregex; | |
915 vn->regex = in_addr[i].regex; | |
916 #endif | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
917 } |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
918 |
593 | 919 if (done) { |
920 break; | |
921 } | |
922 | |
923 in_addr++; | |
924 in_port[p].addrs.elts = in_addr; | |
925 last--; | |
926 | |
927 a = 0; | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
928 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
929 } |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
930 |
589 | 931 #if 0 |
455 | 932 { |
933 u_char address[20]; | |
589 | 934 ngx_uint_t p, a; |
455 | 935 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
936 in_port = in_ports.elts; |
56
058f01f78761
nginx-0.0.1-2003-01-29-20:02:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
937 for (p = 0; p < in_ports.nelts; p++) { |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
938 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, |
461 | 939 "port: %d %p", in_port[p].port, &in_port[p]); |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
940 in_addr = in_port[p].addrs.elts; |
89
29bf798b583f
nginx-0.0.1-2003-05-15-19:42:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
88
diff
changeset
|
941 for (a = 0; a < in_port[p].addrs.nelts; a++) { |
455 | 942 ngx_inet_ntop(AF_INET, &in_addr[a].addr, address, 20); |
943 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, cf->log, 0, | |
461 | 944 "%s:%d %p", |
455 | 945 address, in_port[p].port, in_addr[a].core_srv_conf); |
593 | 946 name = in_addr[a].names.elts; |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
947 for (n = 0; n < in_addr[a].names.nelts; n++) { |
455 | 948 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, cf->log, 0, |
461 | 949 "%s:%d %V %p", |
593 | 950 address, in_port[p].port, &name[n].name, |
951 name[n].core_srv_conf); | |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
952 } |
56
058f01f78761
nginx-0.0.1-2003-01-29-20:02:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
953 } |
058f01f78761
nginx-0.0.1-2003-01-29-20:02:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
954 } |
455 | 955 } |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
956 #endif |
56
058f01f78761
nginx-0.0.1-2003-01-29-20:02:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
55
diff
changeset
|
957 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
958 return NGX_CONF_OK; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
41
diff
changeset
|
959 } |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
960 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
961 |
455 | 962 /* |
963 * add the server address, the server names and the server core module | |
964 * configurations to the port (in_port) | |
965 */ | |
966 | |
499 | 967 static ngx_int_t |
593 | 968 ngx_http_add_address(ngx_conf_t *cf, ngx_http_conf_in_port_t *in_port, |
499 | 969 ngx_http_listen_t *lscf, ngx_http_core_srv_conf_t *cscf) |
455 | 970 { |
593 | 971 ngx_http_conf_in_addr_t *in_addr; |
455 | 972 |
973 if (in_port->addrs.elts == NULL) { | |
593 | 974 if (ngx_array_init(&in_port->addrs, cf->temp_pool, 4, |
1385 | 975 sizeof(ngx_http_conf_in_addr_t)) |
976 != NGX_OK) | |
455 | 977 { |
978 return NGX_ERROR; | |
979 } | |
980 } | |
981 | |
501 | 982 in_addr = ngx_array_push(&in_port->addrs); |
983 if (in_addr == NULL) { | |
455 | 984 return NGX_ERROR; |
985 } | |
986 | |
987 in_addr->addr = lscf->addr; | |
593 | 988 in_addr->hash.buckets = NULL; |
989 in_addr->hash.size = 0; | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
990 in_addr->wc_head = NULL; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1236
diff
changeset
|
991 in_addr->wc_tail = NULL; |
455 | 992 in_addr->names.elts = NULL; |
1387 | 993 #if (NGX_PCRE) |
994 in_addr->nregex = 0; | |
995 in_addr->regex = NULL; | |
996 #endif | |
455 | 997 in_addr->core_srv_conf = cscf; |
593 | 998 in_addr->default_server = lscf->conf.default_server; |
999 in_addr->bind = lscf->conf.bind; | |
1000 in_addr->listen_conf = &lscf->conf; | |
455 | 1001 |
1002 #if (NGX_DEBUG) | |
1003 { | |
1004 u_char text[20]; | |
1005 ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20); | |
1006 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, "address: %s:%d", | |
1007 text, in_port->port); | |
1008 } | |
1009 #endif | |
1010 | |
1011 return ngx_http_add_names(cf, in_addr, cscf); | |
1012 } | |
1013 | |
1014 | |
1015 /* | |
1016 * add the server names and the server core module | |
1017 * configurations to the address:port (in_addr) | |
1018 */ | |
1019 | |
499 | 1020 static ngx_int_t |
593 | 1021 ngx_http_add_names(ngx_conf_t *cf, ngx_http_conf_in_addr_t *in_addr, |
499 | 1022 ngx_http_core_srv_conf_t *cscf) |
455 | 1023 { |
477 | 1024 ngx_uint_t i, n; |
455 | 1025 ngx_http_server_name_t *server_names, *name; |
1026 | |
1027 if (in_addr->names.elts == NULL) { | |
593 | 1028 if (ngx_array_init(&in_addr->names, cf->temp_pool, 4, |
1385 | 1029 sizeof(ngx_http_server_name_t)) |
1030 != NGX_OK) | |
477 | 1031 { |
1032 return NGX_ERROR; | |
1033 } | |
1034 } | |
1035 | |
455 | 1036 server_names = cscf->server_names.elts; |
1387 | 1037 |
455 | 1038 for (i = 0; i < cscf->server_names.nelts; i++) { |
1039 | |
477 | 1040 for (n = 0; n < server_names[i].name.len; n++) { |
1041 server_names[i].name.data[n] = | |
1042 ngx_tolower(server_names[i].name.data[n]); | |
1043 } | |
1044 | |
455 | 1045 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0, |
461 | 1046 "name: %V", &server_names[i].name); |
455 | 1047 |
593 | 1048 name = ngx_array_push(&in_addr->names); |
501 | 1049 if (name == NULL) { |
455 | 1050 return NGX_ERROR; |
1051 } | |
1052 | |
1053 *name = server_names[i]; | |
1054 } | |
1055 | |
1056 return NGX_OK; | |
1057 } | |
1058 | |
1059 | |
499 | 1060 static char * |
1061 ngx_http_merge_locations(ngx_conf_t *cf, ngx_array_t *locations, | |
1062 void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index) | |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1063 { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1064 char *rv; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1065 ngx_uint_t i; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1066 ngx_http_core_loc_conf_t **clcfp; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1067 |
593 | 1068 clcfp = locations->elts; |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1069 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1070 for (i = 0; i < locations->nelts; i++) { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1071 rv = module->merge_loc_conf(cf, loc_conf[ctx_index], |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1072 clcfp[i]->loc_conf[ctx_index]); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1073 if (rv != NGX_CONF_OK) { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1074 return rv; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1075 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1076 |
1236
5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
Igor Sysoev <igor@sysoev.ru>
parents:
1209
diff
changeset
|
1077 if (clcfp[i]->locations == NULL) { |
5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
Igor Sysoev <igor@sysoev.ru>
parents:
1209
diff
changeset
|
1078 continue; |
5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
Igor Sysoev <igor@sysoev.ru>
parents:
1209
diff
changeset
|
1079 } |
5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
Igor Sysoev <igor@sysoev.ru>
parents:
1209
diff
changeset
|
1080 |
5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
Igor Sysoev <igor@sysoev.ru>
parents:
1209
diff
changeset
|
1081 rv = ngx_http_merge_locations(cf, clcfp[i]->locations, |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1082 clcfp[i]->loc_conf, module, ctx_index); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1083 if (rv != NGX_CONF_OK) { |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1084 return rv; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1085 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1086 } |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1087 |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1088 return NGX_CONF_OK; |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
368
diff
changeset
|
1089 } |
593 | 1090 |
1091 | |
1209
c6c33f81fd79
use stable search where it is required
Igor Sysoev <igor@sysoev.ru>
parents:
751
diff
changeset
|
1092 static int |
593 | 1093 ngx_http_cmp_conf_in_addrs(const void *one, const void *two) |
1094 { | |
1095 ngx_http_conf_in_addr_t *first, *second; | |
1096 | |
1097 first = (ngx_http_conf_in_addr_t *) one; | |
1098 second = (ngx_http_conf_in_addr_t *) two; | |
1099 | |
1100 if (first->addr == INADDR_ANY) { | |
1101 /* the INADDR_ANY must be the last resort, shift it to the end */ | |
1102 return 1; | |
1103 } | |
1104 | |
1105 if (first->bind && !second->bind) { | |
1106 /* shift explicit bind()ed addresses to the start */ | |
1107 return -1; | |
1108 } | |
1109 | |
1110 if (!first->bind && second->bind) { | |
1111 /* shift explicit bind()ed addresses to the start */ | |
1112 return 1; | |
1113 } | |
1114 | |
1115 /* do not sort by default */ | |
1116 | |
1117 return 0; | |
1118 } | |
1119 | |
1120 | |
1121 static int ngx_libc_cdecl | |
1122 ngx_http_cmp_dns_wildcards(const void *one, const void *two) | |
1123 { | |
1124 ngx_hash_key_t *first, *second; | |
1125 | |
1126 first = (ngx_hash_key_t *) one; | |
1127 second = (ngx_hash_key_t *) two; | |
1128 | |
1129 return ngx_strcmp(first->key.data, second->key.data); | |
1130 } |