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