Mercurial > hg > nginx
diff src/http/ngx_http_file_cache.c @ 2944:f892042956e3 stable-0.7
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
various proxy/fastcgi cache features and fixes:
*) report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
*) delete useless r->cache->uses
*) proxy_cache_use_stale/fastcgi_cache_use_stale updating
*) inherit proxy_set_header, proxy_hide_header, and fastcgi_hide_header
only if cache settings are similar
*) add response file uniq while loading cold cache on demand
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 15 Jun 2009 09:30:59 +0000 |
parents | b3b8c66bd520 |
children | 4f28e63e42b4 |
line wrap: on
line diff
--- a/src/http/ngx_http_file_cache.c Mon Jun 15 09:05:31 2009 +0000 +++ b/src/http/ngx_http_file_cache.c Mon Jun 15 09:30:59 2009 +0000 @@ -172,9 +172,8 @@ rc = ngx_http_file_cache_exists(cache, c); - ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "http file cache exists: %i u:%ui e:%d", - rc, c->uses, c->exists); + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http file cache exists: %i e:%d", rc, c->exists); if (rc == NGX_ERROR) { return rc; @@ -321,6 +320,7 @@ c->node->uses = 1; c->node->body_start = c->body_start; c->node->exists = 1; + c->node->uniq = of.uniq; cache->sh->size += (c->length + cache->bsize - 1) / cache->bsize; } @@ -332,16 +332,25 @@ if (c->valid_sec < now) { - c->uses = c->min_uses; + ngx_shmtx_lock(&cache->shpool->mutex); - ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "http file cache expired: %T %T", c->valid_sec, now); + if (c->node->updating) { + rc = NGX_HTTP_CACHE_UPDATING; - return NGX_HTTP_CACHE_STALE; + } else { + c->node->updating = 1; + rc = NGX_HTTP_CACHE_STALE; + } + + ngx_shmtx_unlock(&cache->shpool->mutex); + + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http file cache expired: %i %T %T", + rc, c->valid_sec, now); + + return rc; } - /* TODO: NGX_HTTP_CACHE_AGED */ - return NGX_OK; } @@ -442,7 +451,6 @@ ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); c->uniq = fcn->uniq; - c->uses = fcn->uses; c->error = fcn->error; c->node = fcn; @@ -654,6 +662,8 @@ c->node->exists = 1; } + c->node->updating = 0; + ngx_shmtx_unlock(&cache->shpool->mutex); } @@ -736,6 +746,8 @@ c->node->error = c->error; } + c->node->updating = 0; + ngx_shmtx_unlock(&cache->shpool->mutex); if (c->temp_file) {