summaryrefslogtreecommitdiffhomepage
path: root/src/event
diff options
context:
space:
mode:
Diffstat (limited to 'src/event')
-rw-r--r--src/event/modules/ngx_aio_module.c5
-rw-r--r--src/event/modules/ngx_devpoll_module.c13
-rw-r--r--src/event/modules/ngx_kqueue_module.c9
-rw-r--r--src/event/modules/ngx_kqueue_module.h5
-rw-r--r--src/event/modules/ngx_poll_module.c7
-rw-r--r--src/event/modules/ngx_select_module.c9
-rw-r--r--src/event/ngx_event.c60
-rw-r--r--src/event/ngx_event.h11
-rw-r--r--src/event/ngx_event_accept.c2
-rw-r--r--src/event/ngx_event_timer.c2
10 files changed, 56 insertions, 67 deletions
diff --git a/src/event/modules/ngx_aio_module.c b/src/event/modules/ngx_aio_module.c
index afb343ef2..cc48926de 100644
--- a/src/event/modules/ngx_aio_module.c
+++ b/src/event/modules/ngx_aio_module.c
@@ -29,7 +29,6 @@ ngx_os_io_t ngx_os_aio = {
static ngx_str_t aio_name = ngx_string("aio");
ngx_event_module_t ngx_aio_module_ctx = {
- NGX_EVENT_MODULE,
&aio_name,
NULL, /* create configuration */
NULL, /* init configuration */
@@ -49,10 +48,10 @@ ngx_event_module_t ngx_aio_module_ctx = {
};
ngx_module_t ngx_aio_module = {
+ NGX_MODULE,
&ngx_aio_module_ctx, /* module context */
- 0, /* module index */
NULL, /* module directives */
- NGX_EVENT_MODULE_TYPE, /* module type */
+ NGX_EVENT_MODULE, /* module type */
NULL /* init module */
};
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c
index 531e96a24..27396fcde 100644
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -72,12 +72,11 @@ static ngx_command_t ngx_devpoll_commands[] = {
offsetof(ngx_devpoll_conf_t, events),
NULL},
- {ngx_string(""), 0, NULL, 0, 0, NULL}
+ ngx_null_command
};
ngx_event_module_t ngx_devpoll_module_ctx = {
- NGX_EVENT_MODULE,
&devpoll_name,
ngx_devpoll_create_conf, /* create configuration */
ngx_devpoll_init_conf, /* init configuration */
@@ -97,10 +96,10 @@ ngx_event_module_t ngx_devpoll_module_ctx = {
};
ngx_module_t ngx_devpoll_module = {
+ NGX_MODULE,
&ngx_devpoll_module_ctx, /* module context */
- 0, /* module index */
ngx_devpoll_commands, /* module directives */
- NGX_EVENT_MODULE_TYPE, /* module type */
+ NGX_EVENT_MODULE, /* module type */
NULL /* init module */
};
@@ -109,7 +108,7 @@ static int ngx_devpoll_init(ngx_log_t *log)
{
ngx_devpoll_conf_t *dpcf;
- dpcf = ngx_event_get_conf(ngx_devpoll_module_ctx);
+ dpcf = ngx_event_get_conf(ngx_devpoll_module);
ngx_log_debug(log, "CH: %d" _ dpcf->changes);
ngx_log_debug(log, "EV: %d" _ dpcf->events);
@@ -194,7 +193,7 @@ static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
ngx_event_t *e;
#if (NGX_DEBUG_EVENT)
- ngx_connection_t *c = (ngx_connection_t *) ev->data;
+ ngx_connection_t *c = ev->data;
ngx_log_debug(c->log, "del event: %d, %d" _ c->fd _ event);
#endif
@@ -229,7 +228,7 @@ static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
{
- int n;
+ int n;
ngx_connection_t *c;
c = ev->data;
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 7a38d0a5e..f1688bbd2 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -47,12 +47,11 @@ static ngx_command_t ngx_kqueue_commands[] = {
offsetof(ngx_kqueue_conf_t, events),
NULL},
- {ngx_string(""), 0, NULL, 0, 0, NULL}
+ ngx_null_command
};
ngx_event_module_t ngx_kqueue_module_ctx = {
- NGX_EVENT_MODULE,
&kqueue_name,
ngx_kqueue_create_conf, /* create configuration */
ngx_kqueue_init_conf, /* init configuration */
@@ -72,10 +71,10 @@ ngx_event_module_t ngx_kqueue_module_ctx = {
};
ngx_module_t ngx_kqueue_module = {
+ NGX_MODULE,
&ngx_kqueue_module_ctx, /* module context */
- 0, /* module index */
ngx_kqueue_commands, /* module directives */
- NGX_EVENT_MODULE_TYPE, /* module type */
+ NGX_EVENT_MODULE, /* module type */
NULL /* init module */
};
@@ -84,7 +83,7 @@ static int ngx_kqueue_init(ngx_log_t *log)
{
ngx_kqueue_conf_t *kcf;
- kcf = ngx_event_get_conf(ngx_kqueue_module_ctx);
+ kcf = ngx_event_get_conf(ngx_kqueue_module);
ngx_log_debug(log, "CH: %d" _ kcf->changes);
ngx_log_debug(log, "EV: %d" _ kcf->events);
diff --git a/src/event/modules/ngx_kqueue_module.h b/src/event/modules/ngx_kqueue_module.h
index 72b85d235..2f1757f73 100644
--- a/src/event/modules/ngx_kqueue_module.h
+++ b/src/event/modules/ngx_kqueue_module.h
@@ -8,8 +8,9 @@ typedef struct {
} ngx_kqueue_conf_t;
-extern int ngx_kqueue;
-/* STUB */ extern ngx_event_module_t ngx_kqueue_module_ctx;
+extern int ngx_kqueue;
+extern ngx_module_t ngx_kqueue_module;
+extern ngx_event_module_t ngx_kqueue_module_ctx;
diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c
index 5ca6e939e..adb147d81 100644
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -27,7 +27,6 @@ static ngx_event_t **ready_index;
static ngx_str_t poll_name = ngx_string("poll");
ngx_event_module_t ngx_poll_module_ctx = {
- NGX_EVENT_MODULE,
&poll_name,
NULL, /* create configuration */
NULL, /* init configuration */
@@ -47,10 +46,10 @@ ngx_event_module_t ngx_poll_module_ctx = {
};
ngx_module_t ngx_poll_module = {
+ NGX_MODULE,
&ngx_poll_module_ctx, /* module context */
- 0, /* module index */
NULL, /* module directives */
- NGX_EVENT_MODULE_TYPE, /* module type */
+ NGX_EVENT_MODULE, /* module type */
NULL /* init module */
};
@@ -60,7 +59,7 @@ static int ngx_poll_init(ngx_log_t *log)
{
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_module_ctx);
+ ecf = ngx_event_get_conf(ngx_event_module);
ngx_test_null(event_list,
ngx_alloc(sizeof(struct pollfd) * ecf->connections, log),
diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c
index b1f2c9d46..4b8391c9c 100644
--- a/src/event/modules/ngx_select_module.c
+++ b/src/event/modules/ngx_select_module.c
@@ -40,7 +40,6 @@ static ngx_event_t **ready_index;
static ngx_str_t select_name = ngx_string("select");
ngx_event_module_t ngx_select_module_ctx = {
- NGX_EVENT_MODULE,
&select_name,
NULL, /* create configuration */
ngx_select_init_conf, /* init configuration */
@@ -60,10 +59,10 @@ ngx_event_module_t ngx_select_module_ctx = {
};
ngx_module_t ngx_select_module = {
+ NGX_MODULE,
&ngx_select_module_ctx, /* module context */
- 0, /* module index */
NULL, /* module directives */
- NGX_EVENT_MODULE_TYPE, /* module type */
+ NGX_EVENT_MODULE, /* module type */
NULL /* init module */
};
@@ -72,7 +71,7 @@ static int ngx_select_init(ngx_log_t *log)
{
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_module_ctx);
+ ecf = ngx_event_get_conf(ngx_event_module);
FD_ZERO(&master_read_fd_set);
FD_ZERO(&master_write_fd_set);
@@ -378,7 +377,7 @@ static char *ngx_select_init_conf(ngx_pool_t *pool, void *conf)
{
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_module_ctx);
+ ecf = ngx_event_get_conf(ngx_event_module);
if (ecf->connections > FD_SETSIZE) {
return "maximum number of connections "
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
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 1df1ad39f..3e27ab0c0 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -17,9 +17,6 @@
-/* STUB */
-#define NGX_LOWAT 10000
-
#define NGX_INVALID_INDEX 0x80000000
@@ -319,10 +316,9 @@ extern int ngx_event_flags;
#endif
-#define NGX_EVENT_MODULE_TYPE 0x544E5645 /* "EVNT" */
+#define NGX_EVENT_MODULE 0x544E5645 /* "EVNT" */
#define NGX_EVENT_CONF 0x00200000
-#define NGX_EVENT_MODULE 0
typedef struct {
@@ -333,7 +329,6 @@ typedef struct {
typedef struct {
- int index;
ngx_str_t *name;
void *(*create_conf)(ngx_pool_t *p);
@@ -344,11 +339,11 @@ typedef struct {
extern ngx_module_t ngx_events_module;
-extern ngx_event_module_t ngx_event_module_ctx;
+extern ngx_module_t ngx_event_module;
#define ngx_event_get_conf(module) \
- (*(ngx_get_conf(ngx_events_module))) [module.index];
+ (*(ngx_get_conf(ngx_events_module))) [module.ctx_index];
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index 76eae62d9..c69427fd2 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -162,6 +162,6 @@ void ngx_event_accept(ngx_event_t *ev)
}
} while (ev->available);
-
+
return;
}
diff --git a/src/event/ngx_event_timer.c b/src/event/ngx_event_timer.c
index 03e29d9c4..44fb14a57 100644
--- a/src/event/ngx_event_timer.c
+++ b/src/event/ngx_event_timer.c
@@ -20,7 +20,7 @@ int ngx_event_timer_init(ngx_log_t *log)
int i;
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_module_ctx);
+ ecf = ngx_event_get_conf(ngx_event_module);
ngx_timer_queue_num = ecf->timer_queues;
ngx_timer_cur_queue = 0;