Skip to content

Commit 07b9b3b

Browse files
committed
bugfix: when the entry coroutine was yielded by coroutine.yield() then after it was resumed automatically its status would still be "suspended".
1 parent 889a24a commit 07b9b3b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ngx_http_lua_util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,13 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
987987
"lua coroutine: yield");
988988

989989
ctx->co_op = NGX_HTTP_LUA_USER_CORO_NOP;
990+
990991
if (ctx->cur_co_ctx->co == ctx->entry_co_ctx.co) {
991992
/* entry coroutine yielded will be resumed
992993
* immediately */
993994

995+
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_RUNNING;
996+
994997
ngx_http_lua_probe_entry_coroutine_yield(r,
995998
ctx->cur_co_ctx->co);
996999

t/091-coroutine.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,23 @@ parent: status: running
903903
--- error_log
904904
lua coroutine: runtime error: [string "content_by_lua"]:4: bad
905905
906+
907+
908+
=== TEST 22: entry coroutine is yielded by hand and still gets the right status
909+
--- config
910+
location /t {
911+
content_by_lua '
912+
local co = coroutine.running()
913+
ngx.say("status: ", coroutine.status(co))
914+
coroutine.yield(co)
915+
ngx.say("status: ", coroutine.status(co))
916+
';
917+
}
918+
--- request
919+
GET /t
920+
--- response_body
921+
status: running
922+
status: running
923+
--- no_error_log
924+
[error]
925+

0 commit comments

Comments
 (0)