initialize of.uniq in ngx_open_cached_file()

This commit is contained in:
Igor Sysoev 2008-06-23 13:35:34 +00:00
parent ce1e64f404
commit 3e6f74da05
7 changed files with 18 additions and 9 deletions

View File

@ -189,7 +189,9 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
} }
if ((file->event && file->use_event) 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) { if (file->err == 0) {

View File

@ -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); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
of.uniq = 0;
of.test_dir = 0; of.test_dir = 0;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = clcf->open_file_cache_min_uses; of.min_uses = clcf->open_file_cache_min_uses;

View File

@ -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); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
of.uniq = 0;
of.test_dir = 0; of.test_dir = 0;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = clcf->open_file_cache_min_uses; of.min_uses = clcf->open_file_cache_min_uses;

View File

@ -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); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "open index \"%V\"", &path);
of.uniq = 0;
of.test_dir = 0; of.test_dir = 0;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = clcf->open_file_cache_min_uses; 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, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http index check dir: \"%V\"", &dir); "http index check dir: \"%V\"", &dir);
of.uniq = 0;
of.test_dir = 1; of.test_dir = 1;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = 0; of.min_uses = 0;

View File

@ -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); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
of.uniq = 0;
of.test_dir = 0; of.test_dir = 0;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = clcf->open_file_cache_min_uses; of.min_uses = clcf->open_file_cache_min_uses;

View File

@ -639,14 +639,6 @@ sendfile(r, filename, offset = -1, bytes = 0)
XSRETURN_EMPTY; 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.len = ngx_strlen(filename);
path.data = ngx_pnalloc(r->pool, path.len + 1); 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); (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) if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
!= NGX_OK) != NGX_OK)
{ {

View File

@ -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); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
of.uniq = 0;
of.test_dir = 0; of.test_dir = 0;
of.valid = clcf->open_file_cache_valid; of.valid = clcf->open_file_cache_valid;
of.min_uses = clcf->open_file_cache_min_uses; of.min_uses = clcf->open_file_cache_min_uses;