Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin
6 years ago
328 | 328 | |
329 | 329 | found = 0; |
330 | 330 | |
331 | for (i = 0; ngx_modules[i]; i++) { | |
332 | ||
333 | cmd = ngx_modules[i]->commands; | |
331 | for (i = 0; cf->cycle->modules[i]; i++) { | |
332 | ||
333 | cmd = cf->cycle->modules[i]->commands; | |
334 | 334 | if (cmd == NULL) { |
335 | 335 | continue; |
336 | 336 | } |
347 | 347 | |
348 | 348 | found = 1; |
349 | 349 | |
350 | if (ngx_modules[i]->type != NGX_CONF_MODULE | |
351 | && ngx_modules[i]->type != cf->module_type) | |
350 | if (cf->cycle->modules[i]->type != NGX_CONF_MODULE | |
351 | && cf->cycle->modules[i]->type != cf->module_type) | |
352 | 352 | { |
353 | 353 | continue; |
354 | 354 | } |
410 | 410 | conf = NULL; |
411 | 411 | |
412 | 412 | if (cmd->type & NGX_DIRECT_CONF) { |
413 | conf = ((void **) cf->ctx)[ngx_modules[i]->index]; | |
413 | conf = ((void **) cf->ctx)[cf->cycle->modules[i]->index]; | |
414 | 414 | |
415 | 415 | } else if (cmd->type & NGX_MAIN_CONF) { |
416 | conf = &(((void **) cf->ctx)[ngx_modules[i]->index]); | |
416 | conf = &(((void **) cf->ctx)[cf->cycle->modules[i]->index]); | |
417 | 417 | |
418 | 418 | } else if (cf->ctx) { |
419 | 419 | confp = *(void **) ((char *) cf->ctx + cmd->conf); |
420 | 420 | |
421 | 421 | if (confp) { |
422 | conf = confp[ngx_modules[i]->ctx_index]; | |
422 | conf = confp[cf->cycle->modules[i]->ctx_index]; | |
423 | 423 | } |
424 | 424 | } |
425 | 425 |
211 | 211 | ngx_strlow(cycle->hostname.data, (u_char *) hostname, cycle->hostname.len); |
212 | 212 | |
213 | 213 | |
214 | for (i = 0; ngx_modules[i]; i++) { | |
215 | if (ngx_modules[i]->type != NGX_CORE_MODULE) { | |
214 | cycle->modules = ngx_modules; | |
215 | ||
216 | ||
217 | for (i = 0; cycle->modules[i]; i++) { | |
218 | if (cycle->modules[i]->type != NGX_CORE_MODULE) { | |
216 | 219 | continue; |
217 | 220 | } |
218 | 221 | |
219 | module = ngx_modules[i]->ctx; | |
222 | module = cycle->modules[i]->ctx; | |
220 | 223 | |
221 | 224 | if (module->create_conf) { |
222 | 225 | rv = module->create_conf(cycle); |
224 | 227 | ngx_destroy_pool(pool); |
225 | 228 | return NULL; |
226 | 229 | } |
227 | cycle->conf_ctx[ngx_modules[i]->index] = rv; | |
230 | cycle->conf_ctx[cycle->modules[i]->index] = rv; | |
228 | 231 | } |
229 | 232 | } |
230 | 233 | |
275 | 278 | cycle->conf_file.data); |
276 | 279 | } |
277 | 280 | |
278 | for (i = 0; ngx_modules[i]; i++) { | |
279 | if (ngx_modules[i]->type != NGX_CORE_MODULE) { | |
281 | for (i = 0; cycle->modules[i]; i++) { | |
282 | if (cycle->modules[i]->type != NGX_CORE_MODULE) { | |
280 | 283 | continue; |
281 | 284 | } |
282 | 285 | |
283 | module = ngx_modules[i]->ctx; | |
286 | module = cycle->modules[i]->ctx; | |
284 | 287 | |
285 | 288 | if (module->init_conf) { |
286 | if (module->init_conf(cycle, cycle->conf_ctx[ngx_modules[i]->index]) | |
289 | if (module->init_conf(cycle, | |
290 | cycle->conf_ctx[cycle->modules[i]->index]) | |
287 | 291 | == NGX_CONF_ERROR) |
288 | 292 | { |
289 | 293 | environ = senv; |
46 | 46 | ngx_connection_t **files; |
47 | 47 | ngx_connection_t *free_connections; |
48 | 48 | ngx_uint_t free_connection_n; |
49 | ||
50 | ngx_module_t **modules; | |
49 | 51 | |
50 | 52 | ngx_queue_t reusable_connections_queue; |
51 | 53 |
31 | 31 | { |
32 | 32 | ngx_uint_t i; |
33 | 33 | |
34 | for (i = 0; ngx_modules[i]; i++) { | |
35 | if (ngx_modules[i]->init_module) { | |
36 | if (ngx_modules[i]->init_module(cycle) != NGX_OK) { | |
34 | for (i = 0; cycle->modules[i]; i++) { | |
35 | if (cycle->modules[i]->init_module) { | |
36 | if (cycle->modules[i]->init_module(cycle) != NGX_OK) { | |
37 | 37 | return NGX_ERROR; |
38 | 38 | } |
39 | 39 | } |
52 | 52 | |
53 | 53 | /* count appropriate modules, set up their indices */ |
54 | 54 | |
55 | for (i = 0; ngx_modules[i]; i++) { | |
56 | if (ngx_modules[i]->type != type) { | |
55 | for (i = 0; cycle->modules[i]; i++) { | |
56 | if (cycle->modules[i]->type != type) { | |
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | |
60 | ngx_modules[i]->ctx_index = max++; | |
60 | cycle->modules[i]->ctx_index = max++; | |
61 | 61 | } |
62 | 62 | |
63 | 63 | return max; |
605 | 605 | return NGX_ERROR; |
606 | 606 | } |
607 | 607 | |
608 | for (m = 0; ngx_modules[m]; m++) { | |
609 | if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | |
608 | for (m = 0; cycle->modules[m]; m++) { | |
609 | if (cycle->modules[m]->type != NGX_EVENT_MODULE) { | |
610 | 610 | continue; |
611 | 611 | } |
612 | 612 | |
613 | if (ngx_modules[m]->ctx_index != ecf->use) { | |
613 | if (cycle->modules[m]->ctx_index != ecf->use) { | |
614 | 614 | continue; |
615 | 615 | } |
616 | 616 | |
617 | module = ngx_modules[m]->ctx; | |
617 | module = cycle->modules[m]->ctx; | |
618 | 618 | |
619 | 619 | if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) { |
620 | 620 | /* fatal */ |
904 | 904 | |
905 | 905 | *(void **) conf = ctx; |
906 | 906 | |
907 | for (i = 0; ngx_modules[i]; i++) { | |
908 | if (ngx_modules[i]->type != NGX_EVENT_MODULE) { | |
907 | for (i = 0; cf->cycle->modules[i]; i++) { | |
908 | if (cf->cycle->modules[i]->type != NGX_EVENT_MODULE) { | |
909 | 909 | continue; |
910 | 910 | } |
911 | 911 | |
912 | m = ngx_modules[i]->ctx; | |
912 | m = cf->cycle->modules[i]->ctx; | |
913 | 913 | |
914 | 914 | if (m->create_conf) { |
915 | (*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle); | |
916 | if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) { | |
915 | (*ctx)[cf->cycle->modules[i]->ctx_index] = | |
916 | m->create_conf(cf->cycle); | |
917 | if ((*ctx)[cf->cycle->modules[i]->ctx_index] == NULL) { | |
917 | 918 | return NGX_CONF_ERROR; |
918 | 919 | } |
919 | 920 | } |
932 | 933 | return rv; |
933 | 934 | } |
934 | 935 | |
935 | for (i = 0; ngx_modules[i]; i++) { | |
936 | if (ngx_modules[i]->type != NGX_EVENT_MODULE) { | |
936 | for (i = 0; cf->cycle->modules[i]; i++) { | |
937 | if (cf->cycle->modules[i]->type != NGX_EVENT_MODULE) { | |
937 | 938 | continue; |
938 | 939 | } |
939 | 940 | |
940 | m = ngx_modules[i]->ctx; | |
941 | m = cf->cycle->modules[i]->ctx; | |
941 | 942 | |
942 | 943 | if (m->init_conf) { |
943 | rv = m->init_conf(cf->cycle, (*ctx)[ngx_modules[i]->ctx_index]); | |
944 | rv = m->init_conf(cf->cycle, | |
945 | (*ctx)[cf->cycle->modules[i]->ctx_index]); | |
944 | 946 | if (rv != NGX_CONF_OK) { |
945 | 947 | return rv; |
946 | 948 | } |
1001 | 1003 | } |
1002 | 1004 | |
1003 | 1005 | |
1004 | for (m = 0; ngx_modules[m]; m++) { | |
1005 | if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | |
1006 | for (m = 0; cf->cycle->modules[m]; m++) { | |
1007 | if (cf->cycle->modules[m]->type != NGX_EVENT_MODULE) { | |
1006 | 1008 | continue; |
1007 | 1009 | } |
1008 | 1010 | |
1009 | module = ngx_modules[m]->ctx; | |
1011 | module = cf->cycle->modules[m]->ctx; | |
1010 | 1012 | if (module->name->len == value[1].len) { |
1011 | 1013 | if (ngx_strcmp(module->name->data, value[1].data) == 0) { |
1012 | ecf->use = ngx_modules[m]->ctx_index; | |
1014 | ecf->use = cf->cycle->modules[m]->ctx_index; | |
1013 | 1015 | ecf->name = module->name->data; |
1014 | 1016 | |
1015 | 1017 | if (ngx_process == NGX_PROCESS_SINGLE |
1224 | 1226 | #endif |
1225 | 1227 | |
1226 | 1228 | if (module == NULL) { |
1227 | for (i = 0; ngx_modules[i]; i++) { | |
1228 | ||
1229 | if (ngx_modules[i]->type != NGX_EVENT_MODULE) { | |
1229 | for (i = 0; cycle->modules[i]; i++) { | |
1230 | ||
1231 | if (cycle->modules[i]->type != NGX_EVENT_MODULE) { | |
1230 | 1232 | continue; |
1231 | 1233 | } |
1232 | 1234 | |
1233 | event_module = ngx_modules[i]->ctx; | |
1235 | event_module = cycle->modules[i]->ctx; | |
1234 | 1236 | |
1235 | 1237 | if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0) |
1236 | 1238 | { |
1237 | 1239 | continue; |
1238 | 1240 | } |
1239 | 1241 | |
1240 | module = ngx_modules[i]; | |
1242 | module = cycle->modules[i]; | |
1241 | 1243 | break; |
1242 | 1244 | } |
1243 | 1245 | } |
559 | 559 | return NGX_CONF_ERROR; |
560 | 560 | } |
561 | 561 | |
562 | for (i = 0; ngx_modules[i]; i++) { | |
563 | if (ngx_modules[i]->type != NGX_HTTP_MODULE) { | |
562 | for (i = 0; cf->cycle->modules[i]; i++) { | |
563 | if (cf->cycle->modules[i]->type != NGX_HTTP_MODULE) { | |
564 | 564 | continue; |
565 | 565 | } |
566 | 566 | |
567 | module = ngx_modules[i]->ctx; | |
567 | module = cf->cycle->modules[i]->ctx; | |
568 | 568 | |
569 | 569 | if (module->create_loc_conf) { |
570 | 570 | |
573 | 573 | return NGX_CONF_ERROR; |
574 | 574 | } |
575 | 575 | |
576 | ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf; | |
576 | ctx->loc_conf[cf->cycle->modules[i]->ctx_index] = mconf; | |
577 | 577 | } |
578 | 578 | } |
579 | 579 |
182 | 182 | * of the all http modules |
183 | 183 | */ |
184 | 184 | |
185 | for (m = 0; ngx_modules[m]; m++) { | |
186 | if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
185 | for (m = 0; cf->cycle->modules[m]; m++) { | |
186 | if (cf->cycle->modules[m]->type != NGX_HTTP_MODULE) { | |
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
190 | module = ngx_modules[m]->ctx; | |
191 | mi = ngx_modules[m]->ctx_index; | |
190 | module = cf->cycle->modules[m]->ctx; | |
191 | mi = cf->cycle->modules[m]->ctx_index; | |
192 | 192 | |
193 | 193 | if (module->create_main_conf) { |
194 | 194 | ctx->main_conf[mi] = module->create_main_conf(cf); |
215 | 215 | pcf = *cf; |
216 | 216 | cf->ctx = ctx; |
217 | 217 | |
218 | for (m = 0; ngx_modules[m]; m++) { | |
219 | if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
218 | for (m = 0; cf->cycle->modules[m]; m++) { | |
219 | if (cf->cycle->modules[m]->type != NGX_HTTP_MODULE) { | |
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | module = ngx_modules[m]->ctx; | |
223 | module = cf->cycle->modules[m]->ctx; | |
224 | 224 | |
225 | 225 | if (module->preconfiguration) { |
226 | 226 | if (module->preconfiguration(cf) != NGX_OK) { |
247 | 247 | cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; |
248 | 248 | cscfp = cmcf->servers.elts; |
249 | 249 | |
250 | for (m = 0; ngx_modules[m]; m++) { | |
251 | if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
250 | for (m = 0; cf->cycle->modules[m]; m++) { | |
251 | if (cf->cycle->modules[m]->type != NGX_HTTP_MODULE) { | |
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
255 | module = ngx_modules[m]->ctx; | |
256 | mi = ngx_modules[m]->ctx_index; | |
255 | module = cf->cycle->modules[m]->ctx; | |
256 | mi = cf->cycle->modules[m]->ctx_index; | |
257 | 257 | |
258 | 258 | /* init http{} main_conf's */ |
259 | 259 | |
296 | 296 | } |
297 | 297 | |
298 | 298 | |
299 | for (m = 0; ngx_modules[m]; m++) { | |
300 | if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
299 | for (m = 0; cf->cycle->modules[m]; m++) { | |
300 | if (cf->cycle->modules[m]->type != NGX_HTTP_MODULE) { | |
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
304 | module = ngx_modules[m]->ctx; | |
304 | module = cf->cycle->modules[m]->ctx; | |
305 | 305 | |
306 | 306 | if (module->postconfiguration) { |
307 | 307 | if (module->postconfiguration(cf) != NGX_OK) { |
2967 | 2967 | return NGX_CONF_ERROR; |
2968 | 2968 | } |
2969 | 2969 | |
2970 | for (i = 0; ngx_modules[i]; i++) { | |
2971 | if (ngx_modules[i]->type != NGX_HTTP_MODULE) { | |
2970 | for (i = 0; cf->cycle->modules[i]; i++) { | |
2971 | if (cf->cycle->modules[i]->type != NGX_HTTP_MODULE) { | |
2972 | 2972 | continue; |
2973 | 2973 | } |
2974 | 2974 | |
2975 | module = ngx_modules[i]->ctx; | |
2975 | module = cf->cycle->modules[i]->ctx; | |
2976 | 2976 | |
2977 | 2977 | if (module->create_srv_conf) { |
2978 | 2978 | mconf = module->create_srv_conf(cf); |
2980 | 2980 | return NGX_CONF_ERROR; |
2981 | 2981 | } |
2982 | 2982 | |
2983 | ctx->srv_conf[ngx_modules[i]->ctx_index] = mconf; | |
2983 | ctx->srv_conf[cf->cycle->modules[i]->ctx_index] = mconf; | |
2984 | 2984 | } |
2985 | 2985 | |
2986 | 2986 | if (module->create_loc_conf) { |
2989 | 2989 | return NGX_CONF_ERROR; |
2990 | 2990 | } |
2991 | 2991 | |
2992 | ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf; | |
2992 | ctx->loc_conf[cf->cycle->modules[i]->ctx_index] = mconf; | |
2993 | 2993 | } |
2994 | 2994 | } |
2995 | 2995 | |
3085 | 3085 | return NGX_CONF_ERROR; |
3086 | 3086 | } |
3087 | 3087 | |
3088 | for (i = 0; ngx_modules[i]; i++) { | |
3089 | if (ngx_modules[i]->type != NGX_HTTP_MODULE) { | |
3088 | for (i = 0; cf->cycle->modules[i]; i++) { | |
3089 | if (cf->cycle->modules[i]->type != NGX_HTTP_MODULE) { | |
3090 | 3090 | continue; |
3091 | 3091 | } |
3092 | 3092 | |
3093 | module = ngx_modules[i]->ctx; | |
3093 | module = cf->cycle->modules[i]->ctx; | |
3094 | 3094 | |
3095 | 3095 | if (module->create_loc_conf) { |
3096 | ctx->loc_conf[ngx_modules[i]->ctx_index] = | |
3096 | ctx->loc_conf[cf->cycle->modules[i]->ctx_index] = | |
3097 | 3097 | module->create_loc_conf(cf); |
3098 | if (ctx->loc_conf[ngx_modules[i]->ctx_index] == NULL) { | |
3098 | if (ctx->loc_conf[cf->cycle->modules[i]->ctx_index] == NULL) { | |
3099 | 3099 | return NGX_CONF_ERROR; |
3100 | 3100 | } |
3101 | 3101 | } |
4606 | 4606 | return NGX_CONF_ERROR; |
4607 | 4607 | } |
4608 | 4608 | |
4609 | for (i = 0; ngx_modules[i]; i++) { | |
4610 | if (ngx_modules[i]->type != NGX_HTTP_MODULE) { | |
4609 | for (i = 0; cf->cycle->modules[i]; i++) { | |
4610 | if (cf->cycle->modules[i]->type != NGX_HTTP_MODULE) { | |
4611 | 4611 | continue; |
4612 | 4612 | } |
4613 | 4613 | |
4614 | module = ngx_modules[i]->ctx; | |
4614 | module = cf->cycle->modules[i]->ctx; | |
4615 | 4615 | |
4616 | 4616 | if (module->create_loc_conf) { |
4617 | 4617 | |
4620 | 4620 | return NGX_CONF_ERROR; |
4621 | 4621 | } |
4622 | 4622 | |
4623 | ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf; | |
4623 | ctx->loc_conf[cf->cycle->modules[i]->ctx_index] = mconf; | |
4624 | 4624 | } |
4625 | 4625 | } |
4626 | 4626 |
5330 | 5330 | return NGX_CONF_ERROR; |
5331 | 5331 | } |
5332 | 5332 | |
5333 | for (m = 0; ngx_modules[m]; m++) { | |
5334 | if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | |
5333 | for (m = 0; cf->cycle->modules[m]; m++) { | |
5334 | if (cf->cycle->modules[m]->type != NGX_HTTP_MODULE) { | |
5335 | 5335 | continue; |
5336 | 5336 | } |
5337 | 5337 | |
5338 | module = ngx_modules[m]->ctx; | |
5338 | module = cf->cycle->modules[m]->ctx; | |
5339 | 5339 | |
5340 | 5340 | if (module->create_srv_conf) { |
5341 | 5341 | mconf = module->create_srv_conf(cf); |
5343 | 5343 | return NGX_CONF_ERROR; |
5344 | 5344 | } |
5345 | 5345 | |
5346 | ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
5346 | ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf; | |
5347 | 5347 | } |
5348 | 5348 | |
5349 | 5349 | if (module->create_loc_conf) { |
5352 | 5352 | return NGX_CONF_ERROR; |
5353 | 5353 | } |
5354 | 5354 | |
5355 | ctx->loc_conf[ngx_modules[m]->ctx_index] = mconf; | |
5355 | ctx->loc_conf[cf->cycle->modules[m]->ctx_index] = mconf; | |
5356 | 5356 | } |
5357 | 5357 | } |
5358 | 5358 |
117 | 117 | * create the main_conf's and the null srv_conf's of the all mail modules |
118 | 118 | */ |
119 | 119 | |
120 | for (m = 0; ngx_modules[m]; m++) { | |
121 | if (ngx_modules[m]->type != NGX_MAIL_MODULE) { | |
120 | for (m = 0; cf->cycle->modules[m]; m++) { | |
121 | if (cf->cycle->modules[m]->type != NGX_MAIL_MODULE) { | |
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | module = ngx_modules[m]->ctx; | |
126 | mi = ngx_modules[m]->ctx_index; | |
125 | module = cf->cycle->modules[m]->ctx; | |
126 | mi = cf->cycle->modules[m]->ctx_index; | |
127 | 127 | |
128 | 128 | if (module->create_main_conf) { |
129 | 129 | ctx->main_conf[mi] = module->create_main_conf(cf); |
161 | 161 | cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index]; |
162 | 162 | cscfp = cmcf->servers.elts; |
163 | 163 | |
164 | for (m = 0; ngx_modules[m]; m++) { | |
165 | if (ngx_modules[m]->type != NGX_MAIL_MODULE) { | |
164 | for (m = 0; cf->cycle->modules[m]; m++) { | |
165 | if (cf->cycle->modules[m]->type != NGX_MAIL_MODULE) { | |
166 | 166 | continue; |
167 | 167 | } |
168 | 168 | |
169 | module = ngx_modules[m]->ctx; | |
170 | mi = ngx_modules[m]->ctx_index; | |
169 | module = cf->cycle->modules[m]->ctx; | |
170 | mi = cf->cycle->modules[m]->ctx_index; | |
171 | 171 | |
172 | 172 | /* init mail{} main_conf's */ |
173 | 173 |
236 | 236 | return NGX_CONF_ERROR; |
237 | 237 | } |
238 | 238 | |
239 | for (m = 0; ngx_modules[m]; m++) { | |
240 | if (ngx_modules[m]->type != NGX_MAIL_MODULE) { | |
241 | continue; | |
242 | } | |
243 | ||
244 | module = ngx_modules[m]->ctx; | |
239 | for (m = 0; cf->cycle->modules[m]; m++) { | |
240 | if (cf->cycle->modules[m]->type != NGX_MAIL_MODULE) { | |
241 | continue; | |
242 | } | |
243 | ||
244 | module = cf->cycle->modules[m]->ctx; | |
245 | 245 | |
246 | 246 | if (module->create_srv_conf) { |
247 | 247 | mconf = module->create_srv_conf(cf); |
249 | 249 | return NGX_CONF_ERROR; |
250 | 250 | } |
251 | 251 | |
252 | ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
252 | ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf; | |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
391 | 391 | #endif |
392 | 392 | |
393 | 393 | if (cscf->protocol == NULL) { |
394 | for (m = 0; ngx_modules[m]; m++) { | |
395 | if (ngx_modules[m]->type != NGX_MAIL_MODULE) { | |
394 | for (m = 0; cf->cycle->modules[m]; m++) { | |
395 | if (cf->cycle->modules[m]->type != NGX_MAIL_MODULE) { | |
396 | 396 | continue; |
397 | 397 | } |
398 | 398 | |
399 | module = ngx_modules[m]->ctx; | |
399 | module = cf->cycle->modules[m]->ctx; | |
400 | 400 | |
401 | 401 | if (module->protocol == NULL) { |
402 | 402 | continue; |
594 | 594 | |
595 | 595 | value = cf->args->elts; |
596 | 596 | |
597 | for (m = 0; ngx_modules[m]; m++) { | |
598 | if (ngx_modules[m]->type != NGX_MAIL_MODULE) { | |
599 | continue; | |
600 | } | |
601 | ||
602 | module = ngx_modules[m]->ctx; | |
597 | for (m = 0; cf->cycle->modules[m]; m++) { | |
598 | if (cf->cycle->modules[m]->type != NGX_MAIL_MODULE) { | |
599 | continue; | |
600 | } | |
601 | ||
602 | module = cf->cycle->modules[m]->ctx; | |
603 | 603 | |
604 | 604 | if (module->protocol |
605 | 605 | && ngx_strcmp(module->protocol->name.data, value[1].data) == 0) |
293 | 293 | exit(2); |
294 | 294 | } |
295 | 295 | |
296 | for (i = 0; ngx_modules[i]; i++) { | |
297 | if (ngx_modules[i]->init_process) { | |
298 | if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) { | |
296 | for (i = 0; cycle->modules[i]; i++) { | |
297 | if (cycle->modules[i]->init_process) { | |
298 | if (cycle->modules[i]->init_process(cycle) == NGX_ERROR) { | |
299 | 299 | /* fatal */ |
300 | 300 | exit(2); |
301 | 301 | } |
309 | 309 | |
310 | 310 | if (ngx_terminate || ngx_quit) { |
311 | 311 | |
312 | for (i = 0; ngx_modules[i]; i++) { | |
313 | if (ngx_modules[i]->exit_process) { | |
314 | ngx_modules[i]->exit_process(cycle); | |
312 | for (i = 0; cycle->modules[i]; i++) { | |
313 | if (cycle->modules[i]->exit_process) { | |
314 | cycle->modules[i]->exit_process(cycle); | |
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
688 | 688 | |
689 | 689 | ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
690 | 690 | |
691 | for (i = 0; ngx_modules[i]; i++) { | |
692 | if (ngx_modules[i]->exit_master) { | |
693 | ngx_modules[i]->exit_master(cycle); | |
691 | for (i = 0; cycle->modules[i]; i++) { | |
692 | if (cycle->modules[i]->exit_master) { | |
693 | cycle->modules[i]->exit_master(cycle); | |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
894 | 894 | ls[i].previous = NULL; |
895 | 895 | } |
896 | 896 | |
897 | for (i = 0; ngx_modules[i]; i++) { | |
898 | if (ngx_modules[i]->init_process) { | |
899 | if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) { | |
897 | for (i = 0; cycle->modules[i]; i++) { | |
898 | if (cycle->modules[i]->init_process) { | |
899 | if (cycle->modules[i]->init_process(cycle) == NGX_ERROR) { | |
900 | 900 | /* fatal */ |
901 | 901 | exit(2); |
902 | 902 | } |
948 | 948 | ngx_uint_t i; |
949 | 949 | ngx_connection_t *c; |
950 | 950 | |
951 | for (i = 0; ngx_modules[i]; i++) { | |
952 | if (ngx_modules[i]->exit_process) { | |
953 | ngx_modules[i]->exit_process(cycle); | |
951 | for (i = 0; cycle->modules[i]; i++) { | |
952 | if (cycle->modules[i]->exit_process) { | |
953 | cycle->modules[i]->exit_process(cycle); | |
954 | 954 | } |
955 | 955 | } |
956 | 956 |
552 | 552 | |
553 | 553 | ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
554 | 554 | |
555 | for (i = 0; ngx_modules[i]; i++) { | |
556 | if (ngx_modules[i]->exit_master) { | |
557 | ngx_modules[i]->exit_master(cycle); | |
555 | for (i = 0; cycle->modules[i]; i++) { | |
556 | if (cycle->modules[i]->exit_master) { | |
557 | cycle->modules[i]->exit_master(cycle); | |
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
765 | 765 | |
766 | 766 | cycle = (ngx_cycle_t *) ngx_cycle; |
767 | 767 | |
768 | for (n = 0; ngx_modules[n]; n++) { | |
769 | if (ngx_modules[n]->init_process) { | |
770 | if (ngx_modules[n]->init_process(cycle) == NGX_ERROR) { | |
768 | for (n = 0; cycle->modules[n]; n++) { | |
769 | if (cycle->modules[n]->init_process) { | |
770 | if (cycle->modules[n]->init_process(cycle) == NGX_ERROR) { | |
771 | 771 | /* fatal */ |
772 | 772 | exit(2); |
773 | 773 | } |
824 | 824 | |
825 | 825 | ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
826 | 826 | |
827 | for (i = 0; ngx_modules[i]; i++) { | |
828 | if (ngx_modules[i]->exit_process) { | |
829 | ngx_modules[i]->exit_process(cycle); | |
827 | for (i = 0; cycle->modules[i]; i++) { | |
828 | if (cycle->modules[i]->exit_process) { | |
829 | cycle->modules[i]->exit_process(cycle); | |
830 | 830 | } |
831 | 831 | } |
832 | 832 |
118 | 118 | * create the main_conf's and the null srv_conf's of the all stream modules |
119 | 119 | */ |
120 | 120 | |
121 | for (m = 0; ngx_modules[m]; m++) { | |
122 | if (ngx_modules[m]->type != NGX_STREAM_MODULE) { | |
121 | for (m = 0; cf->cycle->modules[m]; m++) { | |
122 | if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { | |
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | module = ngx_modules[m]->ctx; | |
127 | mi = ngx_modules[m]->ctx_index; | |
126 | module = cf->cycle->modules[m]->ctx; | |
127 | mi = cf->cycle->modules[m]->ctx_index; | |
128 | 128 | |
129 | 129 | if (module->create_main_conf) { |
130 | 130 | ctx->main_conf[mi] = module->create_main_conf(cf); |
162 | 162 | cmcf = ctx->main_conf[ngx_stream_core_module.ctx_index]; |
163 | 163 | cscfp = cmcf->servers.elts; |
164 | 164 | |
165 | for (m = 0; ngx_modules[m]; m++) { | |
166 | if (ngx_modules[m]->type != NGX_STREAM_MODULE) { | |
165 | for (m = 0; cf->cycle->modules[m]; m++) { | |
166 | if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { | |
167 | 167 | continue; |
168 | 168 | } |
169 | 169 | |
170 | module = ngx_modules[m]->ctx; | |
171 | mi = ngx_modules[m]->ctx_index; | |
170 | module = cf->cycle->modules[m]->ctx; | |
171 | mi = cf->cycle->modules[m]->ctx_index; | |
172 | 172 | |
173 | 173 | /* init stream{} main_conf's */ |
174 | 174 | |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | for (m = 0; ngx_modules[m]; m++) { | |
204 | if (ngx_modules[m]->type != NGX_STREAM_MODULE) { | |
203 | for (m = 0; cf->cycle->modules[m]; m++) { | |
204 | if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { | |
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | |
208 | module = ngx_modules[m]->ctx; | |
208 | module = cf->cycle->modules[m]->ctx; | |
209 | 209 | |
210 | 210 | if (module->postconfiguration) { |
211 | 211 | if (module->postconfiguration(cf) != NGX_OK) { |
198 | 198 | return NGX_CONF_ERROR; |
199 | 199 | } |
200 | 200 | |
201 | for (m = 0; ngx_modules[m]; m++) { | |
202 | if (ngx_modules[m]->type != NGX_STREAM_MODULE) { | |
203 | continue; | |
204 | } | |
205 | ||
206 | module = ngx_modules[m]->ctx; | |
201 | for (m = 0; cf->cycle->modules[m]; m++) { | |
202 | if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { | |
203 | continue; | |
204 | } | |
205 | ||
206 | module = cf->cycle->modules[m]->ctx; | |
207 | 207 | |
208 | 208 | if (module->create_srv_conf) { |
209 | 209 | mconf = module->create_srv_conf(cf); |
211 | 211 | return NGX_CONF_ERROR; |
212 | 212 | } |
213 | 213 | |
214 | ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
214 | ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf; | |
215 | 215 | } |
216 | 216 | } |
217 | 217 |
115 | 115 | |
116 | 116 | uscf->srv_conf = ctx->srv_conf; |
117 | 117 | |
118 | for (m = 0; ngx_modules[m]; m++) { | |
119 | if (ngx_modules[m]->type != NGX_STREAM_MODULE) { | |
120 | continue; | |
121 | } | |
122 | ||
123 | module = ngx_modules[m]->ctx; | |
118 | for (m = 0; cf->cycle->modules[m]; m++) { | |
119 | if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { | |
120 | continue; | |
121 | } | |
122 | ||
123 | module = cf->cycle->modules[m]->ctx; | |
124 | 124 | |
125 | 125 | if (module->create_srv_conf) { |
126 | 126 | mconf = module->create_srv_conf(cf); |
128 | 128 | return NGX_CONF_ERROR; |
129 | 129 | } |
130 | 130 | |
131 | ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
131 | ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf; | |
132 | 132 | } |
133 | 133 | } |
134 | 134 |