mirror of
https://github.com/nginx/nginx.git
synced 2024-12-12 02:09:04 +08:00
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.
This commit is contained in:
parent
e9a7f4f5f6
commit
a73ce28e0a
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user