Mercurial > hg > nginx-vendor-current
diff src/http/ngx_http_file_cache.c @ 590:cde3626b2d0d NGINX_0_8_47
nginx 0.8.47
*) Bugfix: $request_time variable had invalid values for subrequests.
*) Bugfix: errors intercepted by error_page could be cached.
*) Bugfix: a cache manager process my got caught in an endless loop, if
max_size parameter was used; the bug had appeared in 0.8.46.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 28 Jul 2010 00:00:00 +0400 |
parents | b6a5942a4e6a |
children | 09d5f308901f |
line wrap: on
line diff
--- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -161,6 +161,7 @@ ngx_http_file_cache_new(ngx_http_request r->cache = c; c->file.log = r->connection->log; + c->file.fd = NGX_INVALID_FILE; return NGX_OK; } @@ -429,6 +430,7 @@ ngx_http_file_cache_read(ngx_http_reques } else { c->node->updating = 1; + c->updating = 1; rc = NGX_HTTP_CACHE_STALE; } @@ -792,6 +794,7 @@ ngx_http_file_cache_update(ngx_http_requ "http file cache update"); c->updated = 1; + c->updating = 0; cache = c->file_cache; @@ -901,37 +904,35 @@ ngx_http_cache_send(ngx_http_request_t * void -ngx_http_file_cache_free(ngx_http_request_t *r, ngx_temp_file_t *tf) +ngx_http_file_cache_free(ngx_http_cache_t *c, ngx_temp_file_t *tf) { - ngx_http_cache_t *c; ngx_http_file_cache_t *cache; ngx_http_file_cache_node_t *fcn; - c = r->cache; - if (c->updated) { return; } - c->updated = 1; - cache = c->file_cache; - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "http file cache free"); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->file.log, 0, + "http file cache free, fd: %d", c->file.fd); ngx_shmtx_lock(&cache->shpool->mutex); fcn = c->node; fcn->count--; - fcn->updating = 0; + + if (c->updating) { + fcn->updating = 0; + } if (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) { + } else if (!fcn->exists && fcn->count == 0) { ngx_queue_remove(&fcn->queue); ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node); ngx_slab_free_locked(cache->shpool, fcn); @@ -940,14 +941,17 @@ ngx_http_file_cache_free(ngx_http_reques ngx_shmtx_unlock(&cache->shpool->mutex); + c->updated = 1; + c->updating = 0; + if (c->temp_file) { if (tf && tf->file.fd != NGX_INVALID_FILE) { - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->file.log, 0, "http file cache incomplete: \"%s\"", tf->file.name.data); if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) { - ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, + ngx_log_error(NGX_LOG_CRIT, c->file.log, ngx_errno, ngx_delete_file_n " \"%s\" failed", tf->file.name.data); } @@ -961,28 +965,19 @@ ngx_http_file_cache_cleanup(void *data) { ngx_http_cache_t *c = data; - ngx_http_file_cache_t *cache; - if (c->updated) { return; } - c->updated = 1; - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->file.log, 0, "http file cache cleanup"); - if (c->error) { - return; + if (c->updating) { + ngx_log_error(NGX_LOG_ALERT, c->file.log, 0, + "stalled cache updating, error:%ui", c->error); } - cache = c->file_cache; - - ngx_shmtx_lock(&cache->shpool->mutex); - - c->node->count--; - - ngx_shmtx_unlock(&cache->shpool->mutex); + ngx_http_file_cache_free(c, NULL); }