blob: df3cfde5d5a65e87f1c1f88a3780f345e2807d8d [file] [log] [blame]
/*
* 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; cycle->modules[i]; i++) {
if (cycle->modules[i]->init_module) {
if (cycle->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; cycle->modules[i]; i++) {
if (cycle->modules[i]->type != type) {
continue;
}
cycle->modules[i]->ctx_index = max++;
}
return max;
}