changeset 6444:043914d19be8

Cache: report error if slab allocator fails during cache loading.
author Dmitry Volyntsev <xeioex@nginx.com>
date Fri, 18 Mar 2016 14:27:30 +0300
parents fc72784b1f52
children c9d680b00744
files src/http/ngx_http_cache.h src/http/ngx_http_file_cache.c
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/ngx_http_cache.h	Fri Mar 18 06:44:49 2016 +0300
+++ b/src/http/ngx_http_cache.h	Fri Mar 18 14:27:30 2016 +0300
@@ -153,6 +153,8 @@
 
     time_t                           inactive;
 
+    time_t                           fail_time;
+
     ngx_uint_t                       files;
     ngx_uint_t                       loader_files;
     ngx_msec_t                       last;
--- a/src/http/ngx_http_file_cache.c	Fri Mar 18 06:44:49 2016 +0300
+++ b/src/http/ngx_http_file_cache.c	Fri Mar 18 14:27:30 2016 +0300
@@ -2094,6 +2094,12 @@
         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;
         }