]> git.kaiwu.me - nginx.git/commitdiff
Cache: report error if slab allocator fails during cache loading.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 18 Mar 2016 11:27:30 +0000 (14:27 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Fri, 18 Mar 2016 11:27:30 +0000 (14:27 +0300)
src/http/ngx_http_cache.h
src/http/ngx_http_file_cache.c

index d36fa779cc96e394f06aad2a6137b03062cc9e23..e93278d47b8d70a113e1963606d1395f82e47e3e 100644 (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;
index 37c4754098d90eee6fabd9c083562e49a791f3df..c8b19e1ccf5b84233c21fda6c34bc7151e8f4269 100644 (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;
         }