diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2010-07-28 15:49:34 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2010-07-28 15:49:34 +0000 |
| commit | 406a68003cfc3b9907bd40699c4a51df4cee3a5a (patch) | |
| tree | 3375c5abfa5b609b71145b2bec2e918dc67b4aa9 /src/http/ngx_http_file_cache.c | |
| parent | 18b36e5035ec5b96fbc44311df5e5dd426d4e93e (diff) | |
| download | nginx-406a68003cfc3b9907bd40699c4a51df4cee3a5a.tar.gz nginx-406a68003cfc3b9907bd40699c4a51df4cee3a5a.tar.bz2 | |
several changes in cache cleanup handling:
*) now ngx_http_file_cache_cleanup() uses ngx_http_file_cache_free()
*) ngx_http_file_cache_free() interface has been changed to accept r->cache
ngx_http_file_cache_cleanup() must use r->cache, but not r, because
there can be several r->cache's during request processing, r->cache may
be NULL at request finalising, etc.
*) test if updating request does not complete correctly
Diffstat (limited to 'src/http/ngx_http_file_cache.c')
| -rw-r--r-- | src/http/ngx_http_file_cache.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index 3bb705432..a7e5c464e 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -430,6 +430,7 @@ ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c) } else { c->node->updating = 1; + c->updating = 1; rc = NGX_HTTP_CACHE_STALE; } @@ -793,6 +794,7 @@ ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf) "http file cache update"); c->updated = 1; + c->updating = 0; cache = c->file_cache; @@ -902,30 +904,28 @@ ngx_http_cache_send(ngx_http_request_t *r) 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, + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->file.log, 0, "http file cache free"); 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; @@ -941,14 +941,17 @@ ngx_http_file_cache_free(ngx_http_request_t *r, ngx_temp_file_t *tf) 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); } @@ -962,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); } |
