Skip to content

Commit 75e0b16

Browse files
committed
bugfix: use of light threads could lead to connection hanging. thanks mike07026 for the report in #31.
1 parent 7193501 commit 75e0b16

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/ngx_stream_lua_util.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,10 +1727,11 @@ ngx_stream_lua_run_posted_threads(ngx_connection_t *c, lua_State *L,
17271727

17281728
/* rc == NGX_ERROR || rc >= NGX_OK */
17291729

1730-
#if 0
1731-
if (ctx->entered_content_phase) {
1732-
ngx_stream_lua_finalize_session(s, rc);
1733-
}
1730+
#if 1
1731+
if (rc == NGX_OK) {
1732+
ngx_stream_lua_finalize_session(s, NGX_OK);
1733+
return NGX_DONE;
1734+
}
17341735
#endif
17351736

17361737
return rc;

t/098-uthread-wait.t

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,3 +1231,21 @@ $s;
12311231
[error]
12321232
[alert]
12331233

1234+
1235+
1236+
=== TEST 23: hanging bug
1237+
--- stream_server_config
1238+
content_by_lua_block {
1239+
local function foo()
1240+
ngx.say("ok")
1241+
end
1242+
1243+
ngx.sleep(0.001)
1244+
local co = ngx.thread.spawn(foo)
1245+
ngx.thread.wait(co)
1246+
}
1247+
--- stream_response
1248+
ok
1249+
--- no_error_log
1250+
[error]
1251+
[alert]

0 commit comments

Comments
 (0)