diff src/event/ngx_event.c @ 672:f41d4b305d22 NGINX_1_2_0

nginx 1.2.0 *) Bugfix: a segmentation fault might occur in a worker process if the "try_files" directive was used; the bug had appeared in 1.1.19. *) Bugfix: response might be truncated if there were more than IOV_MAX buffers used. *) Bugfix: in the "crop" parameter of the "image_filter" directive. Thanks to Maxim Bublis.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Apr 2012 00:00:00 +0400
parents d0f7a625f27c
children 4dcaf40cc702
line wrap: on
line diff
--- 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 *c
 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_command
 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_com
 
 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,
 }
 
 
+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) {
@@ -471,7 +478,7 @@ ngx_event_module_init(ngx_cycle_t *cycle
                          (ngx_int_t) rlmt.rlim_cur : ccf->rlimit_nofile;
 
             ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
-                          "%ui worker_connections are more than "
+                          "%ui worker_connections exceed "
                           "open file resource limit: %i",
                           ecf->connections, limit);
         }
@@ -489,7 +496,7 @@ ngx_event_module_init(ngx_cycle_t *cycle
     }
 
 
-    /* cl should be equal or bigger than cache line size */
+    /* cl should be equal to or greater than cache line size */
 
     cl = 128;
 
@@ -1116,7 +1123,7 @@ ngx_event_debug_connection(ngx_conf_t *c
 
 
 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;