changeset 2063:67a29af877ed

initialize of.uniq in ngx_open_cached_file()
author Igor Sysoev <igor@sysoev.ru>
date Mon, 23 Jun 2008 13:35:34 +0000
parents 90312b616162
children 0835142149d2
files src/core/ngx_open_file_cache.c src/http/modules/ngx_http_flv_module.c src/http/modules/ngx_http_gzip_static_module.c src/http/modules/ngx_http_index_module.c src/http/modules/ngx_http_static_module.c src/http/modules/perl/nginx.xs src/http/ngx_http_script.c
diffstat 7 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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
         }
 
         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) {
 
--- 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 
 
     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;
--- 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_re
 
     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;
--- 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_
 
         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
     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;
--- 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
 
     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;
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -639,14 +639,6 @@ sendfile(r, filename, offset = -1, bytes
         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
 
     (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)
     {
--- 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_scrip
 
     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;