*) of.test_only to not open file if only stat() is enough
*) of.failed to return exact name of failed syscall
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
index cb70736..6deb0ce 100644
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -130,6 +130,7 @@
time_t now;
uint32_t hash;
ngx_int_t rc;
+ ngx_file_info_t fi;
ngx_pool_cleanup_t *cln;
ngx_cached_open_file_t *file;
ngx_pool_cleanup_file_t *clnf;
@@ -140,6 +141,25 @@
if (cache == NULL) {
+ if (of->test_only) {
+
+ if (ngx_file_info(name->data, &fi) == -1) {
+ of->err = ngx_errno;
+ of->failed = ngx_file_info_n;
+ return NGX_ERROR;
+ }
+
+ of->uniq = ngx_file_uniq(&fi);
+ of->mtime = ngx_file_mtime(&fi);
+ of->size = ngx_file_size(&fi);
+ of->is_dir = ngx_is_dir(&fi);
+ of->is_file = ngx_is_file(&fi);
+ of->is_link = ngx_is_link(&fi);
+ of->is_exec = ngx_is_exec(&fi);
+
+ return NGX_OK;
+ }
+
cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));
if (cln == NULL) {
return NGX_ERROR;
@@ -444,6 +464,7 @@
if (of->fd != NGX_INVALID_FILE) {
if (ngx_file_info(name, &fi) == -1) {
+ of->failed = ngx_file_info_n;
goto failed;
}
@@ -454,6 +475,7 @@
} else if (of->test_dir) {
if (ngx_file_info(name, &fi) == -1) {
+ of->failed = ngx_file_info_n;
goto failed;
}
@@ -471,6 +493,7 @@
}
if (fd == NGX_INVALID_FILE) {
+ of->failed = ngx_open_file_n;
goto failed;
}