<div dir="ltr">Will this patch be applied to mainline?<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 27, 2014 at 8:23 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
On Wed, Mar 26, 2014 at 01:34:19PM +0400, kyprizel wrote:<br>
<br>
> will be "log_alloc_failures" better?<br>
<br>
I think something like "log_nomem" will be good enough.<br>
Patch:<br>
<br>
# HG changeset patch<br>
# User Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>><br>
# Date 1395937285 -14400<br>
# Thu Mar 27 20:21:25 2014 +0400<br>
# Node ID 2cc8b9fc7efbf6a98ce29f3f860782a1ebd7e6cf<br>
# Parent 734f0babfc133c2dc532f2794deadcf9d90245f7<br>
Core: slab log_nomem flag.<br>
<br>
The flag allows to suppress "ngx_slab_alloc() failed: no memory" messages<br>
from a slab allocator, e.g., if an LRU expiration is used by a consumer<br>
and allocation failures aren't fatal.<br>
<br>
The flag is now set in the SSL session cache code, and in the limit_req<br>
module.<br>
<br>
diff --git a/src/core/ngx_slab.c b/src/core/ngx_slab.c<br>
--- a/src/core/ngx_slab.c<br>
+++ b/src/core/ngx_slab.c<br>
@@ -129,6 +129,7 @@ ngx_slab_init(ngx_slab_pool_t *pool)<br>
pool->pages->slab = pages;<br>
}<br>
<br>
+ pool->log_nomem = 1;<br>
pool->log_ctx = &pool->zero;<br>
pool->zero = '\0';<br>
}<br>
@@ -658,7 +659,10 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po<br>
}<br>
}<br>
<br>
- ngx_slab_error(pool, NGX_LOG_CRIT, "ngx_slab_alloc() failed: no memory");<br>
+ if (pool->log_nomem) {<br>
+ ngx_slab_error(pool, NGX_LOG_CRIT,<br>
+ "ngx_slab_alloc() failed: no memory");<br>
+ }<br>
<br>
return NULL;<br>
}<br>
diff --git a/src/core/ngx_slab.h b/src/core/ngx_slab.h<br>
--- a/src/core/ngx_slab.h<br>
+++ b/src/core/ngx_slab.h<br>
@@ -39,6 +39,8 @@ typedef struct {<br>
u_char *log_ctx;<br>
u_char zero;<br>
<br>
+ unsigned log_nomem:1;<br>
+<br>
void *data;<br>
void *addr;<br>
} ngx_slab_pool_t;<br>
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c<br>
--- a/src/event/ngx_event_openssl.c<br>
+++ b/src/event/ngx_event_openssl.c<br>
@@ -1834,6 +1834,8 @@ ngx_ssl_session_cache_init(ngx_shm_zone_<br>
ngx_sprintf(shpool->log_ctx, " in SSL session shared cache \"%V\"%Z",<br>
&shm_zone-><a href="http://shm.name" target="_blank">shm.name</a>);<br>
<br>
+ shpool->log_nomem = 0;<br>
+<br>
return NGX_OK;<br>
}<br>
<br>
@@ -1986,7 +1988,7 @@ failed:<br>
ngx_shmtx_unlock(&shpool->mutex);<br>
<br>
ngx_log_error(NGX_LOG_ALERT, c->log, 0,<br>
- "could not add new SSL session to the session cache");<br>
+ "could not allocate new session%s", shpool->log_ctx);<br>
<br>
return 0;<br>
}<br>
diff --git a/src/http/modules/ngx_http_limit_req_module.c b/src/http/modules/ngx_http_limit_req_module.c<br>
--- a/src/http/modules/ngx_http_limit_req_module.c<br>
+++ b/src/http/modules/ngx_http_limit_req_module.c<br>
@@ -451,6 +451,8 @@ ngx_http_limit_req_lookup(ngx_http_limit<br>
<br>
node = ngx_slab_alloc_locked(ctx->shpool, size);<br>
if (node == NULL) {<br>
+ ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,<br>
+ "could not allocate node%s", ctx->shpool->log_ctx);<br>
return NGX_ERROR;<br>
}<br>
}<br>
@@ -674,6 +676,8 @@ ngx_http_limit_req_init_zone(ngx_shm_zon<br>
ngx_sprintf(ctx->shpool->log_ctx, " in limit_req zone \"%V\"%Z",<br>
&shm_zone-><a href="http://shm.name" target="_blank">shm.name</a>);<br>
<br>
+ ctx->shpool->log_nomem = 0;<br>
+<br>
return NGX_OK;<br>
<div class="HOEnZb"><div class="h5"> }<br>
<br>
<br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" target="_blank">http://nginx.org/</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div>