aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_module.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2016-02-04 18:30:21 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2016-02-04 18:30:21 +0300
commit798833457018ee8a6274ec78e816f747361c0d47 (patch)
treea8a905538380af822e90b3fc5571de836c3b3aba /src/core/ngx_module.c
parent9add42c71e71c2af8e67eceeeb773d22a9cab760 (diff)
downloadnginx-798833457018ee8a6274ec78e816f747361c0d47.tar.gz
nginx-798833457018ee8a6274ec78e816f747361c0d47.zip
Dynamic modules: moved module-related stuff to separate files.
Diffstat (limited to 'src/core/ngx_module.c')
-rw-r--r--src/core/ngx_module.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/core/ngx_module.c b/src/core/ngx_module.c
new file mode 100644
index 000000000..dc4e91f34
--- /dev/null
+++ b/src/core/ngx_module.c
@@ -0,0 +1,65 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) Maxim Dounin
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+ngx_uint_t ngx_max_module;
+
+
+ngx_int_t
+ngx_preinit_modules()
+{
+ ngx_uint_t i;
+
+ ngx_max_module = 0;
+ for (i = 0; ngx_modules[i]; i++) {
+ ngx_modules[i]->index = ngx_max_module++;
+ }
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_init_modules(ngx_cycle_t *cycle)
+{
+ ngx_uint_t i;
+
+ for (i = 0; ngx_modules[i]; i++) {
+ if (ngx_modules[i]->init_module) {
+ if (ngx_modules[i]->init_module(cycle) != NGX_OK) {
+ return NGX_ERROR;
+ }
+ }
+ }
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_count_modules(ngx_cycle_t *cycle, ngx_uint_t type)
+{
+ ngx_uint_t i, max;
+
+ max = 0;
+
+ /* count appropriate modules, set up their indices */
+
+ for (i = 0; ngx_modules[i]; i++) {
+ if (ngx_modules[i]->type != type) {
+ continue;
+ }
+
+ ngx_modules[i]->ctx_index = max++;
+ }
+
+ return max;
+}