Skip to content

Commit a276476

Browse files
hy05190134zhuizhuhaomeng
authored andcommitted
change: use nil instead of false when lpush&rpush overflow.
Co-authered-by: lijunlong<lijunlong@openresty.com>
1 parent b67b22a commit a276476

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/ngx_http_lua_shdict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ ngx_http_lua_shdict_push_helper(lua_State *L, int flags)
943943

944944
ngx_shmtx_unlock(&ctx->shpool->mutex);
945945

946-
lua_pushboolean(L, 0);
946+
lua_pushnil(L);
947947
lua_pushliteral(L, "no memory");
948948
return 2;
949949
}

t/145-shdict-list.t

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,3 +827,27 @@ GET /test
827827
aa list value: nil
828828
--- no_error_log
829829
[error]
830+
831+
832+
833+
=== TEST 22: lpush return nil
834+
--- http_config
835+
lua_shared_dict dogs 100k;
836+
--- config
837+
location = /test {
838+
content_by_lua_block {
839+
local dogs = ngx.shared.dogs
840+
for i = 1, 2920
841+
do
842+
local len, err = dogs:lpush("foo", "bar")
843+
end
844+
local len, err = dogs:lpush("foo", "bar")
845+
ngx.say(len)
846+
}
847+
}
848+
--- request
849+
GET /test
850+
--- response_body
851+
nil
852+
--- no_error_log
853+
[error]

0 commit comments

Comments
 (0)