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

Dmitry Volyntsev xeioex at nginx.com
Fri Mar 18 11:28:27 UTC 2016


details:   http://hg.nginx.org/nginx/rev/043914d19be8
branches:  
changeset: 6444:043914d19be8
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Fri Mar 18 14:27:30 2016 +0300
description:
Cache: report error if slab allocator fails during cache loading.

diffstat:

 src/http/ngx_http_cache.h      |  2 ++
 src/http/ngx_http_file_cache.c |  6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diffs (28 lines):

diff -r fc72784b1f52 -r 043914d19be8 src/http/ngx_http_cache.h
--- 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 @@ 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;
diff -r fc72784b1f52 -r 043914d19be8 src/http/ngx_http_file_cache.c
--- 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 @@ ngx_http_file_cache_add(ngx_http_file_ca
         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;
         }



More information about the nginx-devel mailing list