Skip to content

Commit d8c45b8

Browse files
committed
feature: make use of the new shm API in nginx 1.5.13+ to suppress the "no memory" error logging when the shared dicts run out of memory.
1 parent ae2207b commit d8c45b8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/ngx_http_lua_shdict.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ ngx_http_lua_shdict_init_zone(ngx_shm_zone_t *shm_zone, void *data)
9191
ngx_sprintf(ctx->shpool->log_ctx, " in lua_shared_dict zone \"%V\"%Z",
9292
&shm_zone->shm.name);
9393

94+
#if defined(nginx_version) && nginx_version >= 1005013
95+
ctx->shpool->log_nomem = 0;
96+
#endif
97+
9498
done:
9599
dd("get lmcf");
96100

t/043-shdict.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use Test::Nginx::Socket::Lua;
88

99
#repeat_each(2);
1010

11-
plan tests => repeat_each() * (blocks() * 3 + 15);
11+
plan tests => repeat_each() * (blocks() * 3 + 17);
1212

1313
#no_diff();
1414
no_long_string();
@@ -401,10 +401,10 @@ GET /test
401401
--- response_body
402402
false no memory false
403403
--- log_level: info
404-
--- error_log eval
405-
qr/\[info\] .* ngx_slab_alloc\(\) failed: no memory in lua_shared_dict zone "dogs"/
406404
--- no_error_log
407405
[error]
406+
[crit]
407+
ngx_slab_alloc() failed: no memory in lua_shared_dict zone
408408

409409

410410

@@ -706,10 +706,10 @@ GET /test
706706
--- response_body
707707
false no memory true
708708
--- log_level: info
709-
--- error_log eval
710-
qr/\[info\] .* ngx_slab_alloc\(\) failed: no memory in lua_shared_dict zone "dogs"/
711709
--- no_error_log
712710
[error]
711+
[crit]
712+
ngx_slab_alloc() failed: no memory in lua_shared_dict zone
713713

714714

715715

0 commit comments

Comments
 (0)