diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-04-27 13:55:53 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-04-27 13:55:53 +0400 |
commit | f1cc457d7f562a7c8e7ff9ba28fc143bd175a7dc (patch) | |
tree | f3c4ae29d70a5dfd1f42dfe10174a7cbcbb9bdeb /src/core/ngx_open_file_cache.c | |
parent | 0e60e4f73a62bf168dcc0ece770dafa27de35207 (diff) |
*) of.test_only to not open file if only stat() is enough
*) of.failed to return exact name of failed syscall
Diffstat (limited to 'src/core/ngx_open_file_cache.c')
-rw-r--r-- | src/core/ngx_open_file_cache.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index cb7073675..6deb0ce0b 100644 --- a/src/core/ngx_open_file_cache.c +++ b/src/core/ngx_open_file_cache.c @@ -130,6 +130,7 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, 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 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, 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 @@ ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) 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 @@ ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) } else if (of->test_dir) { if (ngx_file_info(name, &fi) == -1) { + of->failed = ngx_file_info_n; goto failed; } @@ -471,6 +493,7 @@ ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) } if (fd == NGX_INVALID_FILE) { + of->failed = ngx_open_file_n; goto failed; } |