comparison src/core/ngx_module.c @ 6378:0f203a2af17c

Dynamic modules: moved module-related stuff to separate files.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 04 Feb 2016 18:30:21 +0300
parents
children cf5e822cf470
comparison
equal deleted inserted replaced
6377:11e019750adc 6378:0f203a2af17c
1
2 /*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Maxim Dounin
5 * Copyright (C) Nginx, Inc.
6 */
7
8
9 #include <ngx_config.h>
10 #include <ngx_core.h>
11
12
13 ngx_uint_t ngx_max_module;
14
15
16 ngx_int_t
17 ngx_preinit_modules()
18 {
19 ngx_uint_t i;
20
21 ngx_max_module = 0;
22 for (i = 0; ngx_modules[i]; i++) {
23 ngx_modules[i]->index = ngx_max_module++;
24 }
25
26 return NGX_OK;
27 }
28
29
30 ngx_int_t
31 ngx_init_modules(ngx_cycle_t *cycle)
32 {
33 ngx_uint_t i;
34
35 for (i = 0; ngx_modules[i]; i++) {
36 if (ngx_modules[i]->init_module) {
37 if (ngx_modules[i]->init_module(cycle) != NGX_OK) {
38 return NGX_ERROR;
39 }
40 }
41 }
42
43 return NGX_OK;
44 }
45
46
47 ngx_int_t
48 ngx_count_modules(ngx_cycle_t *cycle, ngx_uint_t type)
49 {
50 ngx_uint_t i, max;
51
52 max = 0;
53
54 /* count appropriate modules, set up their indices */
55
56 for (i = 0; ngx_modules[i]; i++) {
57 if (ngx_modules[i]->type != type) {
58 continue;
59 }
60
61 ngx_modules[i]->ctx_index = max++;
62 }
63
64 return max;
65 }