diff --git a/src/ngx_stream_lua_timer.c b/src/ngx_stream_lua_timer.c index 00ba37fb..fa0eee21 100644 --- a/src/ngx_stream_lua_timer.c +++ b/src/ngx_stream_lua_timer.c @@ -730,6 +730,8 @@ ngx_stream_lua_timer_handler(ngx_event_t *ev) failed: /* co stack: func [args] */ + lua_pushvalue(tctx.co, 1); + /* co stack: func [args] func */ lua_getinfo(tctx.co, ">Sf", &ar); source = ar.source; diff --git a/t/106-timer.t b/t/106-timer.t index 8b66a0cb..266156e7 100644 --- a/t/106-timer.t +++ b/t/106-timer.t @@ -1910,3 +1910,47 @@ qr/\[alert\] .*? lua failed to run timer with function defined at @.+\/test.lua: [crit] [error] [warn] + + + +=== TEST 33: log function location when failed to run a timer with arg (lua file) +--- user_files +>>> test.lua +local _M = {} + +function _M.run() + ngx.sleep(0.01) +end + +return _M +--- stream_config + lua_package_path '$TEST_NGINX_HTML_DIR/?.lua;./?.lua;;'; + lua_max_running_timers 1; +--- stream_server_config + content_by_lua_block { + local test = require "test" + + local ok, err = ngx.timer.at(0, test.run, "arg") + if not ok then + ngx.say("failed to set timer: ", err) + return + end + + local ok, err = ngx.timer.at(0, test.run, "arg") + if not ok then + ngx.say("failed to set timer: ", err) + return + end + + ngx.say("ok") + } +--- stream_response +ok +--- wait: 0.1 +--- error_log eval +qr/\[alert\] .*? lua failed to run timer with function defined at @.+\/test.lua:3: stream lua: 1 lua_max_running_timers are not enough/ +--- no_error_log +[emerg] +[crit] +[error] +[warn]