From 23f66898463308fdc70ab2659273fb9804f29370 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Mon, 31 Mar 2014 21:38:30 +0400 Subject: 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. --- src/core/ngx_slab.c | 6 +++++- src/core/ngx_slab.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ngx_slab.c b/src/core/ngx_slab.c index 6d18abb72..be7927ce0 100644 --- 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 *pool, ngx_uint_t pages) } } - 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; } diff --git a/src/core/ngx_slab.h b/src/core/ngx_slab.h index c5e420bfa..5735e3bb3 100644 --- a/src/core/ngx_slab.h +++ b/src/core/ngx_slab.h @@ -39,6 +39,8 @@ typedef struct { u_char *log_ctx; u_char zero; + unsigned log_nomem:1; + void *data; void *addr; } ngx_slab_pool_t; -- cgit