diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index 1dc2d131d..87104a04a 100644 --- a/src/core/ngx_open_file_cache.c +++ b/src/core/ngx_open_file_cache.c @@ -353,8 +353,10 @@ create: update: - if (ngx_event_flags & NGX_USE_VNODE_EVENT && of->fd != NGX_INVALID_FILE) { - + if ((ngx_event_flags & NGX_USE_VNODE_EVENT) + && of->events + && of->fd != NGX_INVALID_FILE) + { file->event = ngx_calloc(sizeof(ngx_event_t), pool->log); if (file->event== NULL) { goto failed; diff --git a/src/core/ngx_open_file_cache.h b/src/core/ngx_open_file_cache.h index 90c75909d..cc0d899a2 100644 --- a/src/core/ngx_open_file_cache.h +++ b/src/core/ngx_open_file_cache.h @@ -23,6 +23,7 @@ typedef struct { unsigned test_dir:1; unsigned errors:1; + unsigned events:1; unsigned is_dir:1; unsigned is_file:1; diff --git a/src/http/modules/ngx_http_flv_module.c b/src/http/modules/ngx_http_flv_module.c index ad0d5bd97..04327d938 100644 --- a/src/http/modules/ngx_http_flv_module.c +++ b/src/http/modules/ngx_http_flv_module.c @@ -109,6 +109,7 @@ ngx_http_flv_handler(ngx_http_request_t *r) of.test_dir = 0; of.retest = clcf->open_file_cache_retest; of.errors = clcf->open_file_cache_errors; + of.events = clcf->open_file_cache_events; rc = ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool); diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c index f3f2b61ce..6f81a49cf 100644 --- a/src/http/modules/ngx_http_index_module.c +++ b/src/http/modules/ngx_http_index_module.c @@ -236,6 +236,7 @@ ngx_http_index_handler(ngx_http_request_t *r) of.test_dir = 0; of.retest = clcf->open_file_cache_retest; of.errors = clcf->open_file_cache_errors; + of.events = clcf->open_file_cache_events; rc = ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool); diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c index aa5e72eb9..9278497d9 100644 --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -100,6 +100,7 @@ ngx_http_static_handler(ngx_http_request_t *r) of.test_dir = 0; of.retest = clcf->open_file_cache_retest; of.errors = clcf->open_file_cache_errors; + of.events = clcf->open_file_cache_events; rc = ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool); diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index 8b7ef2250..24379ad9e 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -641,6 +641,7 @@ sendfile(r, filename, offset = -1, bytes = 0) of.test_dir = 0; of.retest = clcf->open_file_cache_retest; of.errors = clcf->open_file_cache_errors; + of.events = clcf->open_file_cache_events; path.len = ngx_strlen(filename); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 9a52678bd..b25346daa 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -471,6 +471,13 @@ static ngx_command_t ngx_http_core_commands[] = { offsetof(ngx_http_core_loc_conf_t, open_file_cache_errors), NULL }, + { ngx_string("open_file_cache_events"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_core_loc_conf_t, open_file_cache_events), + NULL }, + ngx_null_command }; @@ -2375,6 +2382,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf) lcf->open_file_cache = NGX_CONF_UNSET_PTR; lcf->open_file_cache_retest = NGX_CONF_UNSET; lcf->open_file_cache_errors = NGX_CONF_UNSET; + lcf->open_file_cache_events = NGX_CONF_UNSET; return lcf; } @@ -2567,6 +2575,9 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_conf_merge_sec_value(conf->open_file_cache_errors, prev->open_file_cache_errors, 0); + ngx_conf_merge_sec_value(conf->open_file_cache_events, + prev->open_file_cache_events, 0); + return NGX_CONF_OK; } diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 5455c5c12..2bd687e88 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -293,6 +293,7 @@ struct ngx_http_core_loc_conf_s { ngx_open_file_cache_t *open_file_cache; time_t open_file_cache_retest; ngx_flag_t open_file_cache_errors; + ngx_flag_t open_file_cache_events; ngx_log_t *err_log; diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index 78c42722e..b19ee91dc 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -977,6 +977,7 @@ ngx_http_script_file_code(ngx_http_script_engine_t *e) of.test_dir = 0; of.retest = clcf->open_file_cache_retest; of.errors = clcf->open_file_cache_errors; + of.events = clcf->open_file_cache_events; if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) == NGX_ERROR)