Cache: report error if slab allocator fails during cache loading.

This commit is contained in:
Dmitry Volyntsev 2016-03-18 14:27:30 +03:00
parent 348f705c00
commit 861e75dc20
2 changed files with 8 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}