mirror of
https://github.com/nginx/nginx.git
synced 2025-06-09 19:12:47 +08:00
*) delete cache key node after a cache file removal
*) move fileless cache key node removal in ngx_http_file_cache_delete()
This commit is contained in:
parent
0e0e0af51b
commit
2108fabea2
@ -1033,15 +1033,6 @@ ngx_http_file_cache_forced_expire(ngx_http_file_cache_t *cache)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fcn->exists) {
|
|
||||||
|
|
||||||
ngx_queue_remove(q);
|
|
||||||
ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
|
|
||||||
ngx_slab_free_locked(cache->shpool, fcn);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_http_file_cache_delete(cache, q, name);
|
ngx_http_file_cache_delete(cache, q, name);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1131,15 +1122,6 @@ ngx_http_file_cache_expire(ngx_http_file_cache_t *cache)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fcn->exists) {
|
|
||||||
|
|
||||||
ngx_queue_remove(q);
|
|
||||||
ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
|
|
||||||
ngx_slab_free_locked(cache->shpool, fcn);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngx_http_file_cache_delete(cache, q, name);
|
ngx_http_file_cache_delete(cache, q, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,26 +1144,21 @@ ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
|
|||||||
|
|
||||||
fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);
|
fcn = ngx_queue_data(q, ngx_http_file_cache_node_t, queue);
|
||||||
|
|
||||||
|
if (fcn->exists) {
|
||||||
cache->sh->size -= (fcn->length + cache->bsize - 1) / cache->bsize;
|
cache->sh->size -= (fcn->length + cache->bsize - 1) / cache->bsize;
|
||||||
|
|
||||||
path = cache->path;
|
path = cache->path;
|
||||||
|
|
||||||
p = name + path->name.len + 1 + path->len;
|
p = name + path->name.len + 1 + path->len;
|
||||||
|
p = ngx_hex_dump(p, (u_char *) &fcn->node.key,
|
||||||
p = ngx_hex_dump(p, (u_char *) &fcn->node.key, sizeof(ngx_rbtree_key_t));
|
sizeof(ngx_rbtree_key_t));
|
||||||
|
|
||||||
len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);
|
len = NGX_HTTP_CACHE_KEY_LEN - sizeof(ngx_rbtree_key_t);
|
||||||
p = ngx_hex_dump(p, fcn->key, len);
|
p = ngx_hex_dump(p, fcn->key, len);
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
ngx_queue_remove(q);
|
fcn->count++;
|
||||||
ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
|
|
||||||
ngx_slab_free_locked(cache->shpool, fcn);
|
|
||||||
|
|
||||||
ngx_shmtx_unlock(&cache->shpool->mutex);
|
ngx_shmtx_unlock(&cache->shpool->mutex);
|
||||||
|
|
||||||
len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;
|
len = path->name.len + 1 + path->len + 2 * NGX_HTTP_CACHE_KEY_LEN;
|
||||||
|
|
||||||
ngx_create_hashed_filename(path, name, len);
|
ngx_create_hashed_filename(path, name, len);
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||||
@ -1193,6 +1170,14 @@ ngx_http_file_cache_delete(ngx_http_file_cache_t *cache, ngx_queue_t *q,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngx_shmtx_lock(&cache->shpool->mutex);
|
ngx_shmtx_lock(&cache->shpool->mutex);
|
||||||
|
fcn->count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fcn->count == 0) {
|
||||||
|
ngx_queue_remove(q);
|
||||||
|
ngx_rbtree_delete(&cache->sh->rbtree, &fcn->node);
|
||||||
|
ngx_slab_free_locked(cache->shpool, fcn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user