From 3e6f74da0556265b7ad3fbdb629f2898b1e1936f Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Mon, 23 Jun 2008 13:35:34 +0000 Subject: initialize of.uniq in ngx_open_cached_file() --- src/core/ngx_open_file_cache.c | 4 +++- src/http/modules/ngx_http_flv_module.c | 1 + src/http/modules/ngx_http_gzip_static_module.c | 1 + src/http/modules/ngx_http_index_module.c | 2 ++ src/http/modules/ngx_http_static_module.c | 1 + src/http/modules/perl/nginx.xs | 17 +++++++++-------- src/http/ngx_http_script.c | 1 + 7 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index d9ec1881b..4e4c1c5bd 100644 --- a/src/core/ngx_open_file_cache.c +++ b/src/core/ngx_open_file_cache.c @@ -189,7 +189,9 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, } if ((file->event && file->use_event) - || (file->event == NULL && now - file->created < of->valid)) + || (file->event == NULL + && (of->uniq == 0 || of->uniq == file->uniq) + && now - file->created < of->valid)) { if (file->err == 0) { diff --git a/src/http/modules/ngx_http_flv_module.c b/src/http/modules/ngx_http_flv_module.c index 0e190910c..5dedb9e82 100644 --- a/src/http/modules/ngx_http_flv_module.c +++ b/src/http/modules/ngx_http_flv_module.c @@ -105,6 +105,7 @@ ngx_http_flv_handler(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + of.uniq = 0; of.test_dir = 0; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c index e6d44ec7b..a63281a8b 100644 --- a/src/http/modules/ngx_http_gzip_static_module.c +++ b/src/http/modules/ngx_http_gzip_static_module.c @@ -119,6 +119,7 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + of.uniq = 0; of.test_dir = 0; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; diff --git a/src/http/modules/ngx_http_index_module.c b/src/http/modules/ngx_http_index_module.c index bd9c18c9d..096844400 100644 --- a/src/http/modules/ngx_http_index_module.c +++ b/src/http/modules/ngx_http_index_module.c @@ -208,6 +208,7 @@ ngx_http_index_handler(ngx_http_request_t *r) ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "open index \"%V\"", &path); + of.uniq = 0; of.test_dir = 0; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; @@ -291,6 +292,7 @@ ngx_http_index_test_dir(ngx_http_request_t *r, ngx_http_core_loc_conf_t *clcf, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http index check dir: \"%V\"", &dir); + of.uniq = 0; of.test_dir = 1; of.valid = clcf->open_file_cache_valid; of.min_uses = 0; diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c index fc84268dc..9d48fb91b 100644 --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -96,6 +96,7 @@ ngx_http_static_handler(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + of.uniq = 0; of.test_dir = 0; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index de4d20074..cc0fc4ba6 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -639,14 +639,6 @@ sendfile(r, filename, offset = -1, bytes = 0) XSRETURN_EMPTY; } - clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - - of.test_dir = 0; - of.valid = clcf->open_file_cache_valid; - of.min_uses = clcf->open_file_cache_min_uses; - of.errors = clcf->open_file_cache_errors; - of.events = clcf->open_file_cache_events; - path.len = ngx_strlen(filename); path.data = ngx_pnalloc(r->pool, path.len + 1); @@ -656,6 +648,15 @@ sendfile(r, filename, offset = -1, bytes = 0) (void) ngx_cpystrn(path.data, filename, path.len + 1); + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + of.uniq = 0; + of.test_dir = 0; + of.valid = clcf->open_file_cache_valid; + of.min_uses = clcf->open_file_cache_min_uses; + 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_OK) { diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index 0bdb944a9..af6e3098f 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -994,6 +994,7 @@ ngx_http_script_file_code(ngx_http_script_engine_t *e) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + of.uniq = 0; of.test_dir = 0; of.valid = clcf->open_file_cache_valid; of.min_uses = clcf->open_file_cache_min_uses; -- cgit v1.2.3