Skip to content

Commit

Permalink
Cache: report error if slab allocator fails during cache loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeioex committed Mar 18, 2016
1 parent 348f705 commit 861e75d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/http/ngx_http_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ struct ngx_http_file_cache_s {

time_t inactive;

time_t fail_time;

ngx_uint_t files;
ngx_uint_t loader_files;
ngx_msec_t last;
Expand Down
6 changes: 6 additions & 0 deletions src/http/ngx_http_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,12 @@ ngx_http_file_cache_add(ngx_http_file_cache_t *cache, ngx_http_cache_t *c)
fcn = ngx_slab_calloc_locked(cache->shpool,
sizeof(ngx_http_file_cache_node_t));
if (fcn == NULL) {
if (cache->fail_time != ngx_time()) {
cache->fail_time = ngx_time();
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
"could not allocate node%s", cache->shpool->log_ctx);
}

ngx_shmtx_unlock(&cache->shpool->mutex);
return NGX_ERROR;
}
Expand Down

0 comments on commit 861e75d

Please sign in to comment.