aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2011-07-24 16:47:31 +0000
committerIgor Sysoev <igor@sysoev.ru>2011-07-24 16:47:31 +0000
commitc1250b6a491b221b546d9b0f8bbd3ed762f47b67 (patch)
tree810cd8a829e98f17113154799fe32554c04c4b1a /src
parentbb389f6111ce8058fadbc6754b301f05890c5dbe (diff)
downloadnginx-c1250b6a491b221b546d9b0f8bbd3ed762f47b67.tar.gz
nginx-c1250b6a491b221b546d9b0f8bbd3ed762f47b67.zip
The cache loader performs two tasks: inserting cache objects in inactivity
list and evaluating total cache size. Reading just directory is enough for this purpose. Elimination of reading cache files saves at least one disk I/O operation per file. Preparation for elimination of reading cache files by cache loader: removing dependencies on the reading: *) cache node valid_sec and valid_msec are used only for caching errors; *) upstream buffer size can be used instead of cache node body_start.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_file_cache.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index 493e67d1f..50b9e555f 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -533,7 +533,9 @@ ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
if (fcn->exists || fcn->uses >= c->min_uses) {
c->exists = fcn->exists;
- c->body_start = fcn->body_start;
+ if (c->body_start) {
+ c->body_start = fcn->body_start;
+ }
rc = NGX_OK;
@@ -1365,9 +1367,6 @@ ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name)
} else {
c.uniq = ngx_file_uniq(&fi);
- c.valid_sec = h.valid_sec;
- c.valid_msec = h.valid_msec;
- c.body_start = h.body_start;
c.length = ngx_file_size(&fi);
c.fs_size = (ngx_file_fs_size(&fi) + cache->bsize - 1) / cache->bsize;
}
@@ -1377,10 +1376,6 @@ ngx_http_file_cache_add_file(ngx_tree_ctx_t *ctx, ngx_str_t *name)
ngx_close_file_n " \"%s\" failed", name->data);
}
- if (c.body_start == 0) {
- return NGX_ERROR;
- }
-
p = &name->data[name->len - 2 * NGX_HTTP_CACHE_KEY_LEN];
for (i = 0; i < NGX_HTTP_CACHE_KEY_LEN; i++) {
@@ -1426,14 +1421,14 @@ ngx_http_file_cache_add(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
fcn->uses = 1;
fcn->count = 0;
- fcn->valid_msec = c->valid_msec;
+ fcn->valid_msec = 0;
fcn->error = 0;
fcn->exists = 1;
fcn->updating = 0;
fcn->deleting = 0;
fcn->uniq = c->uniq;
- fcn->valid_sec = c->valid_sec;
- fcn->body_start = c->body_start;
+ fcn->valid_sec = 0;
+ fcn->body_start = 0;
fcn->fs_size = c->fs_size;
cache->sh->size += c->fs_size;