Mercurial > hg > nginx
diff src/event/ngx_event.c @ 96:a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 27 May 2003 12:18:54 +0000 |
parents | 738fe44c70d5 |
children | 70d2345a903f |
line wrap: on
line diff
--- a/src/event/ngx_event.c Fri May 23 11:53:01 2003 +0000 +++ b/src/event/ngx_event.c Tue May 27 12:18:54 2003 +0000 @@ -12,12 +12,11 @@ extern ngx_event_module_t ngx_select_module_ctx; #if (HAVE_KQUEUE) -extern ngx_event_module_t ngx_kqueue_module_ctx; #include <ngx_kqueue_module.h> #endif #if (HAVE_DEVPOLL) -extern ngx_event_module_t ngx_devpoll_module_ctx; +extern ngx_module_t ngx_devpoll_module; #endif #if (HAVE_AIO) @@ -30,8 +29,8 @@ #endif -static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); -static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, char *conf); +static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static void *ngx_event_create_conf(ngx_pool_t *pool); static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf); @@ -61,15 +60,15 @@ 0, NULL}, - {ngx_string(""), 0, NULL, 0, 0, NULL} + ngx_null_command }; ngx_module_t ngx_events_module = { + NGX_MODULE, &events_name, /* module context */ - 0, /* module index */ ngx_events_commands, /* module directives */ - NGX_CORE_MODULE_TYPE, /* module type */ + NGX_CORE_MODULE, /* module type */ NULL /* init module */ }; @@ -98,12 +97,11 @@ offsetof(ngx_event_conf_t, timer_queues), NULL}, - {ngx_string(""), 0, NULL, 0, 0, NULL} + ngx_null_command }; ngx_event_module_t ngx_event_module_ctx = { - NGX_EVENT_MODULE, &event_name, ngx_event_create_conf, /* create configuration */ ngx_event_init_conf, /* init configuration */ @@ -113,10 +111,10 @@ ngx_module_t ngx_event_module = { + NGX_MODULE, &ngx_event_module_ctx, /* module context */ - 0, /* module index */ ngx_event_commands, /* module directives */ - NGX_EVENT_MODULE_TYPE, /* module type */ + NGX_EVENT_MODULE, /* module type */ NULL /* init module */ }; @@ -132,18 +130,18 @@ ngx_event_conf_t *ecf; ngx_event_module_t *module; - ecf = ngx_event_get_conf(ngx_event_module_ctx); + ecf = ngx_event_get_conf(ngx_event_module); ngx_log_debug(log, "CONN: %d" _ ecf->connections); ngx_log_debug(log, "TYPE: %d" _ ecf->use); for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { + if (ngx_modules[m]->type != NGX_EVENT_MODULE) { continue; } - module = ngx_modules[m]->ctx; - if (module->index == ecf->use) { + if (ngx_modules[m]->ctx_index == ecf->use) { + module = ngx_modules[m]->ctx; if (module->actions.init(log) == NGX_ERROR) { return NGX_ERROR; } @@ -247,7 +245,7 @@ } -static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf) +static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { int m; char *rv; @@ -259,12 +257,11 @@ ngx_event_max_module = 0; for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { + if (ngx_modules[m]->type != NGX_EVENT_MODULE) { continue; } - module = ngx_modules[m]->ctx; - module->index = ngx_event_max_module++; + ngx_modules[m]->ctx_index = ngx_event_max_module++; } ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(void *)), NGX_CONF_ERROR); @@ -276,21 +273,22 @@ *(void **) conf = ctx; for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { + if (ngx_modules[m]->type != NGX_EVENT_MODULE) { continue; } module = ngx_modules[m]->ctx; if (module->create_conf) { - ngx_test_null((*ctx)[module->index], module->create_conf(cf->pool), + ngx_test_null((*ctx)[ngx_modules[m]->ctx_index], + module->create_conf(cf->pool), NGX_CONF_ERROR); } } pcf = *cf; cf->ctx = ctx; - cf->module_type = NGX_EVENT_MODULE_TYPE; + cf->module_type = NGX_EVENT_MODULE; cf->cmd_type = NGX_EVENT_CONF; rv = ngx_conf_parse(cf, NULL); *cf = pcf; @@ -299,14 +297,14 @@ return rv; for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { + if (ngx_modules[m]->type != NGX_EVENT_MODULE) { continue; } module = ngx_modules[m]->ctx; if (module->init_conf) { - rv = module->init_conf(cf->pool, (*ctx)[module->index]); + rv = module->init_conf(cf->pool, (*ctx)[ngx_modules[m]->ctx_index]); if (rv != NGX_CONF_OK) { return rv; } @@ -317,9 +315,9 @@ } -static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, char *conf) +static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_event_conf_t *ecf = (ngx_event_conf_t *) conf; + ngx_event_conf_t *ecf = conf; int m; ngx_str_t *args; @@ -332,14 +330,14 @@ args = cf->args->elts; for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE_TYPE) { + if (ngx_modules[m]->type != NGX_EVENT_MODULE) { continue; } module = ngx_modules[m]->ctx; if (module->name->len == args[1].len) { if (ngx_strcmp(module->name->data, args[1].data) == 0) { - ecf->use = module->index; + ecf->use = ngx_modules[m]->ctx_index; return NGX_CONF_OK; } } @@ -380,19 +378,19 @@ #endif ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_kqueue_module_ctx.index); + ngx_conf_init_value(ecf->use, ngx_kqueue_module.ctx_index); #elif (HAVE_DEVPOLL) ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_devpoll_module_ctx.index); + ngx_conf_init_value(ecf->use, ngx_devpoll_module.ctx_index); #else /* HAVE_SELECT */ ngx_conf_init_value(ecf->connections, FD_SETSIZE < DEF_CONNECTIONS ? FD_SETSIZE : DEF_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_select_module_ctx.index); + ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index); #endif