[nginx] svn commit: r4600 - trunk/src/event

mdounin at mdounin.ru mdounin at mdounin.ru
Wed Apr 18 14:47:10 UTC 2012


Author: mdounin
Date: 2012-04-18 14:47:10 +0000 (Wed, 18 Apr 2012)
New Revision: 4600
URL: http://trac.nginx.org/nginx/changeset/4600/nginx

Log:
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.


Modified:
   trunk/src/event/ngx_event.c

Modified: trunk/src/event/ngx_event.c
===================================================================
--- trunk/src/event/ngx_event.c	2012-04-18 13:30:43 UTC (rev 4599)
+++ trunk/src/event/ngx_event.c	2012-04-18 14:47:10 UTC (rev 4600)
@@ -21,6 +21,7 @@
 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_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_core_module_t  ngx_events_module_ctx = {
     ngx_string("events"),
     NULL,
-    NULL
+    ngx_event_init_conf
 };
 
 
@@ -173,8 +174,8 @@
 
 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 @@
 }
 
 
+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_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 @@
 
 
 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 @@
 
 
 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;
 



More information about the nginx-devel mailing list