Mercurial > hg > nginx
changeset 3694:dfb17155eca9
delete empty cache zone node if we could not get response to cache
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 15 Jul 2010 13:08:51 +0000 |
parents | e3bcc2f4c418 |
children | 1c016de812af |
files | src/http/ngx_http_file_cache.c |
diffstat | 1 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_file_cache.c Wed Jul 14 11:29:19 2010 +0000 +++ b/src/http/ngx_http_file_cache.c Thu Jul 15 13:08:51 2010 +0000 @@ -835,8 +835,9 @@ void ngx_http_file_cache_free(ngx_http_request_t *r, ngx_temp_file_t *tf) { - ngx_http_cache_t *c; - ngx_http_file_cache_t *cache; + ngx_http_cache_t *c; + ngx_http_file_cache_t *cache; + ngx_http_file_cache_node_t *fcn; c = r->cache; @@ -853,16 +854,22 @@ ngx_shmtx_lock(&cache->shpool->mutex); - c->node->count--; + fcn = c->node; + fcn->count--; + fcn->updating = 0; if (c->error) { - c->node->valid_sec = c->valid_sec; - c->node->valid_msec = c->valid_msec; - c->node->error = c->error; + fcn->valid_sec = c->valid_sec; + fcn->valid_msec = c->valid_msec; + fcn->error = c->error; + + } else if (fcn->valid_msec == 0 && fcn->count == 0) { + ngx_queue_remove(&fcn->queue); + ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); + ngx_slab_free_locked(cache->shpool, fcn); + c->node = NULL; } - c->node->updating = 0; - ngx_shmtx_unlock(&cache->shpool->mutex); if (c->temp_file) {