aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-04-18 14:47:10 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-04-18 14:47:10 +0000
commita73ce28e0a6d855daaf2cd2a40bbf65762e58f2a (patch)
treef9ce8d5be1480ce0fd7eee5fc29a3c5ad19ae5ca /src
parente9a7f4f5f6c2f95e582d1b498b6056a2309da0fa (diff)
downloadnginx-a73ce28e0a6d855daaf2cd2a40bbf65762e58f2a.tar.gz
nginx-a73ce28e0a6d855daaf2cd2a40bbf65762e58f2a.zip
Fixed master exit if there is no events section (ticket #150).
Instead of checking if there is events{} section present in configuration in init_module handler we now do the same in init_conf handler. This allows master process to detect incorrect configuration early and reject it.
Diffstat (limited to 'src')
-rw-r--r--src/event/ngx_event.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index ee9eb9846..a0a9d743b 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -21,6 +21,7 @@ extern ngx_module_t ngx_rtsig_module;
extern ngx_module_t ngx_select_module;
+static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle);
static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle);
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -31,8 +32,8 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
-static void *ngx_event_create_conf(ngx_cycle_t *cycle);
-static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
+static void *ngx_event_core_create_conf(ngx_cycle_t *cycle);
+static char *ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf);
static ngx_uint_t ngx_timer_resolution;
@@ -93,7 +94,7 @@ static ngx_command_t ngx_events_commands[] = {
static ngx_core_module_t ngx_events_module_ctx = {
ngx_string("events"),
NULL,
- NULL
+ ngx_event_init_conf
};
@@ -173,8 +174,8 @@ static ngx_command_t ngx_event_core_commands[] = {
ngx_event_module_t ngx_event_core_module_ctx = {
&event_core_name,
- ngx_event_create_conf, /* create configuration */
- ngx_event_init_conf, /* init configuration */
+ ngx_event_core_create_conf, /* create configuration */
+ ngx_event_core_init_conf, /* init configuration */
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -423,6 +424,19 @@ ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
}
+static char *
+ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
+{
+ if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) {
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "no \"events\" section in configuration");
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
static ngx_int_t
ngx_event_module_init(ngx_cycle_t *cycle)
{
@@ -435,13 +449,6 @@ ngx_event_module_init(ngx_cycle_t *cycle)
ngx_event_conf_t *ecf;
cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
-
- if (cf == NULL) {
- ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
- "no \"events\" section in configuration");
- return NGX_ERROR;
- }
-
ecf = (*cf)[ngx_event_core_module.ctx_index];
if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) {
@@ -1116,7 +1123,7 @@ ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static void *
-ngx_event_create_conf(ngx_cycle_t *cycle)
+ngx_event_core_create_conf(ngx_cycle_t *cycle)
{
ngx_event_conf_t *ecf;
@@ -1147,7 +1154,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle)
static char *
-ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
+ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_event_conf_t *ecf = conf;