summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_file_cache.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2014-06-04 15:09:19 +0400
committerRuslan Ermilov <ru@nginx.com>2014-06-04 15:09:19 +0400
commit05d717b35d02c493533f6244a85b6c78a59f4272 (patch)
tree0be8ef3eb996dc2cacb775005e1d7a734a809ae5 /src/http/ngx_http_file_cache.c
parentd1ba20d0c971f4a76fef5ba8d39e757b9a7fa3af (diff)
downloadnginx-05d717b35d02c493533f6244a85b6c78a59f4272.tar.gz
nginx-05d717b35d02c493533f6244a85b6c78a59f4272.tar.bz2
Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().
These functions return zeroed memory, analogous to ngx_pcalloc().
Diffstat (limited to 'src/http/ngx_http_file_cache.c')
-rw-r--r--src/http/ngx_http_file_cache.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index 49abdb400..4d9e82235 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -678,8 +678,8 @@ ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
goto done;
}
- fcn = ngx_slab_alloc_locked(cache->shpool,
- sizeof(ngx_http_file_cache_node_t));
+ fcn = ngx_slab_calloc_locked(cache->shpool,
+ sizeof(ngx_http_file_cache_node_t));
if (fcn == NULL) {
ngx_shmtx_unlock(&cache->shpool->mutex);
@@ -687,8 +687,8 @@ ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
ngx_shmtx_lock(&cache->shpool->mutex);
- fcn = ngx_slab_alloc_locked(cache->shpool,
- sizeof(ngx_http_file_cache_node_t));
+ fcn = ngx_slab_calloc_locked(cache->shpool,
+ sizeof(ngx_http_file_cache_node_t));
if (fcn == NULL) {
rc = NGX_ERROR;
goto failed;
@@ -704,8 +704,6 @@ ngx_http_file_cache_exists(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
fcn->uses = 1;
fcn->count = 1;
- fcn->updating = 0;
- fcn->deleting = 0;
renew:
@@ -1618,8 +1616,8 @@ ngx_http_file_cache_add(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
if (fcn == NULL) {
- fcn = ngx_slab_alloc_locked(cache->shpool,
- sizeof(ngx_http_file_cache_node_t));
+ fcn = ngx_slab_calloc_locked(cache->shpool,
+ sizeof(ngx_http_file_cache_node_t));
if (fcn == NULL) {
ngx_shmtx_unlock(&cache->shpool->mutex);
return NGX_ERROR;
@@ -1633,15 +1631,7 @@ ngx_http_file_cache_add(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
ngx_rbtree_insert(&cache->sh->rbtree, &fcn->node);
fcn->uses = 1;
- fcn->count = 0;
- fcn->valid_msec = 0;
- fcn->error = 0;
fcn->exists = 1;
- fcn->updating = 0;
- fcn->deleting = 0;
- fcn->uniq = 0;
- fcn->valid_sec = 0;
- fcn->body_start = 0;
fcn->fs_size = c->fs_size;
cache->sh->size += c->fs_size;