diff src/core/ngx_slab.c @ 5634:5024d29354f1

Core: slab log_nomem flag. The flag allows to suppress "ngx_slab_alloc() failed: no memory" messages from a slab allocator, e.g., if an LRU expiration is used by a consumer and allocation failures aren't fatal. The flag is now used in the SSL session cache code, and in the limit_req module.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 31 Mar 2014 21:38:30 +0400
parents 79b9101cecf4
children c46657e391a3
line wrap: on
line diff
--- a/src/core/ngx_slab.c
+++ b/src/core/ngx_slab.c
@@ -129,6 +129,7 @@ ngx_slab_init(ngx_slab_pool_t *pool)
         pool->pages->slab = pages;
     }
 
+    pool->log_nomem = 1;
     pool->log_ctx = &pool->zero;
     pool->zero = '\0';
 }
@@ -658,7 +659,10 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po
         }
     }
 
-    ngx_slab_error(pool, NGX_LOG_CRIT, "ngx_slab_alloc() failed: no memory");
+    if (pool->log_nomem) {
+        ngx_slab_error(pool, NGX_LOG_CRIT,
+                       "ngx_slab_alloc() failed: no memory");
+    }
 
     return NULL;
 }