summaryrefslogtreecommitdiffhomepage
path: root/src/event/ngx_event.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-05-27 12:18:54 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-05-27 12:18:54 +0000
commit6253ca1b62c24bbac8c380d4ae64353b671ad7ef (patch)
treecccc0130b6fb065ff235750d23b817e890bd5e57 /src/event/ngx_event.c
parent187fcd82410e0f9022b0090a27b040eb1211c3f5 (diff)
downloadnginx-6253ca1b62c24bbac8c380d4ae64353b671ad7ef.tar.gz
nginx-6253ca1b62c24bbac8c380d4ae64353b671ad7ef.tar.bz2
nginx-0.0.1-2003-05-27-16:18:54 import
Diffstat (limited to 'src/event/ngx_event.c')
-rw-r--r--src/event/ngx_event.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 9a4796ac1..2361a3f93 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -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 @@ extern ngx_event_module_t ngx_devpoll_module_ctx;
#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 @@ static ngx_command_t ngx_events_commands[] = {
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 @@ static ngx_command_t ngx_event_commands[] = {
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_event_module_t ngx_event_module_ctx = {
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 @@ int ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log)
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 @@ void ngx_worker(ngx_log_t *log)
}
-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 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
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 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
*(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 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
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_events_block(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
}
-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 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, char *conf)
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 @@ static char *ngx_event_init_conf(ngx_pool_t *pool, void *conf)
#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