Skip to content

Commit b028156

Browse files
committed
synchronized with lua-nginx-module #2a19073 (remove error logging on coroutine runtime errors).
1 parent 1b57027 commit b028156

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

src/subsys/ngx_subsys_lua_util.c.tt2

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,14 @@ ngx_[% subsys %]_lua_run_thread(lua_State *L, [% req_type %] *r,
10921092

10931093
NGX_LUA_EXCEPTION_TRY {
10941094

1095+
/*
1096+
* silence a -Werror=clobbered warning with gcc 5.4
1097+
* due to above setjmp
1098+
*/
1099+
err = NULL;
1100+
msg = NULL;
1101+
trace = NULL;
1102+
10951103
if (ctx->cur_co_ctx->thread_spawn_yielded) {
10961104
ngx_[% subsys %]_lua_probe_info("thread spawn yielded");
10971105

@@ -1464,30 +1472,34 @@ user_co_done:
14641472
ctx->cur_co_ctx = orig_coctx;
14651473
}
14661474

1467-
if (lua_isstring(ctx->cur_co_ctx->co, -1)) {
1468-
dd("user custom error msg");
1469-
msg = lua_tostring(ctx->cur_co_ctx->co, -1);
1470-
1471-
} else {
1472-
msg = "unknown reason";
1473-
}
1474-
14751475
ngx_[% subsys %]_lua_cleanup_pending_operation(ctx->cur_co_ctx);
14761476

14771477
ngx_[% subsys %]_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 0);
14781478

14791479
ctx->cur_co_ctx->co_status = NGX_[% SUBSYS %]_LUA_CO_DEAD;
14801480

1481-
ngx_[% subsys %]_lua_thread_traceback(L, ctx->cur_co_ctx->co,
1482-
ctx->cur_co_ctx);
1483-
trace = lua_tostring(L, -1);
1481+
if (orig_coctx->is_uthread
1482+
|| orig_coctx->is_wrap
1483+
|| ngx_[% subsys %]_lua_is_entry_thread(ctx))
1484+
{
1485+
ngx_[% subsys %]_lua_thread_traceback(L, orig_coctx->co,
1486+
orig_coctx);
1487+
trace = lua_tostring(L, -1);
1488+
1489+
if (lua_isstring(orig_coctx->co, -1)) {
1490+
msg = lua_tostring(orig_coctx->co, -1);
1491+
dd("user custom error msg: %s", msg);
14841492

1485-
propagate_error:
1493+
} else {
1494+
msg = "unknown reason";
1495+
}
1496+
}
14861497

1487-
ngx_[% subsys %]_lua_assert(err != NULL && msg != NULL
1488-
&& trace != NULL);
1498+
propagate_error:
14891499

14901500
if (ctx->cur_co_ctx->is_uthread) {
1501+
ngx_[% subsys %]_lua_assert(err != NULL && msg != NULL
1502+
&& trace != NULL);
14911503

14921504
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
14931505
"[% log_prefix %]lua user thread aborted: %s: %s\n%s",
@@ -1538,6 +1550,9 @@ propagate_error:
15381550
}
15391551

15401552
if (ngx_[% subsys %]_lua_is_entry_thread(ctx)) {
1553+
ngx_[% subsys %]_lua_assert(err != NULL && msg != NULL
1554+
&& trace != NULL);
1555+
15411556
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
15421557
"lua entry thread aborted: %s: %s\n%s",
15431558
err, msg, trace);
@@ -1603,9 +1618,6 @@ propagate_error:
16031618
lua_xmove(orig_coctx->co, next_co, 1);
16041619
nrets = 2;
16051620

1606-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1607-
"lua coroutine: %s: %s\n%s", err, msg, trace);
1608-
16091621
/* try resuming on the new coroutine again */
16101622
continue;
16111623
}

0 commit comments

Comments
 (0)