]> git.kaiwu.me - nginx.git/commitdiff
always test root existence for access_log with variables
authorIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jul 2008 09:26:13 +0000 (09:26 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jul 2008 09:26:13 +0000 (09:26 +0000)
src/http/modules/ngx_http_flv_module.c
src/http/modules/ngx_http_gzip_static_module.c
src/http/modules/ngx_http_log_module.c
src/http/modules/ngx_http_static_module.c
src/http/ngx_http_request.h

index a8239f16e3bc6b569d9c908b2751cb608b2318b0..235ccddea1dc7ff1e4679701f62246f53005e1df 100644 (file)
@@ -159,6 +159,8 @@ ngx_http_flv_handler(ngx_http_request_t *r)
         return NGX_DECLINED;
     }
 
+    r->root_tested = 1;
+
     start = 0;
     len = of.size;
     i = 1;
index 41ac0d3eee66c4b01a2ae6d99fc36fbc09e49327..51fe0d56d6bcbfd0a15f093240ffab086de92976 100644 (file)
@@ -175,6 +175,8 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r)
 
 #endif
 
+    r->root_tested = 1;
+
     rc = ngx_http_discard_request_body(r);
 
     if (rc != NGX_OK) {
index ce7559753df9ace153c3d3a8dc2fccebb0779681..5b8adc595698ec67f41cf3ebad081df931901e7b 100644 (file)
@@ -366,7 +366,7 @@ ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
     ngx_http_log_loc_conf_t   *llcf;
     ngx_http_core_loc_conf_t  *clcf;
 
-    if (r->err_status == NGX_HTTP_NOT_FOUND) {
+    if (!r->root_tested) {
 
         /* test root directory existance */
 
@@ -387,10 +387,25 @@ ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
         of.events = clcf->open_file_cache_events;
 
         if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
-                != NGX_OK
-            || !of.is_dir)
+            != NGX_OK)
         {
-            /* no root directory: simulate successfull logging */
+            if (of.err == 0) {
+                /* simulate successfull logging */
+                return len;
+            }
+
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, of.err,
+                          "testing \"%s\" existence failed", path.data);
+
+            /* simulate successfull logging */
+            return len;
+        }
+
+        if (!of.is_dir) {
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ENOTDIR,
+                          "testing \"%s\" existence failed", path.data);
+
+            /* simulate successfull logging */
             return len;
         }
     }
index f5d6971013cf4729e18ee8d891d845b79ed8c543..ce2f0fc653263f52dc8c0b0ae0fa26a7470d1704 100644 (file)
@@ -140,6 +140,8 @@ ngx_http_static_handler(ngx_http_request_t *r)
         return rc;
     }
 
+    r->root_tested = 1;
+
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd);
 
     if (of.is_dir) {
index 1a4eae106e7f0065c7d6fed20db6f9e3882dc994..be22db636e2e32d56e12821eb24fb421a4d62b68 100644 (file)
@@ -469,6 +469,7 @@ struct ngx_http_request_s {
     unsigned                          request_output:1;
     unsigned                          header_sent:1;
     unsigned                          expect_tested:1;
+    unsigned                          root_tested:1;
     unsigned                          done:1;
     unsigned                          utf8:1;