Skip to content

Commit 85388f4

Browse files
rainingmasterzhuizhuhaomeng
authored andcommitted
feature: check the number of parameters for ngx.thread.wait
1 parent d0e56ca commit 85388f4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/ngx_http_lua_uthread.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ ngx_http_lua_uthread_wait(lua_State *L)
125125
coctx = ctx->cur_co_ctx;
126126

127127
nargs = lua_gettop(L);
128+
if (nargs == 0) {
129+
return luaL_error(L, "at least one coroutine should be specified");
130+
}
128131

129132
for (i = 1; i <= nargs; i++) {
130133
sub_co = lua_tothread(L, i);

t/098-uthread-wait.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,3 +1321,22 @@ $s;
13211321
--- no_error_log
13221322
[error]
13231323
[alert]
1324+
1325+
1326+
1327+
=== TEST 23: no parameters for ngx.thread.wait
1328+
--- config
1329+
location /lua {
1330+
content_by_lua_block {
1331+
ngx.thread.wait()
1332+
ngx.say("ok")
1333+
}
1334+
}
1335+
--- request
1336+
GET /lua
1337+
--- response_body_like: 500 Internal Server Error
1338+
--- error_code: 500
1339+
--- error_log
1340+
at least one coroutine should be specified
1341+
--- no_error_log
1342+
[crit]

0 commit comments

Comments
 (0)