aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-06-14 08:49:32 +0100
committerMatthew Wild <mwild1@gmail.com>2020-06-14 08:49:32 +0100
commit3c53df784751cef688a5ff41db26d4d11b7da2f7 (patch)
treed181a798c4ea2545f6d0fd5e2b4abfc4baaa7f02 /util
parentefcf7cb7d423525536b15bc4347ceb227556260e (diff)
downloadprosody-3c53df784751cef688a5ff41db26d4d11b7da2f7.tar.gz
prosody-3c53df784751cef688a5ff41db26d4d11b7da2f7.zip
util.async: Call coroutine.close() on dead threads (Lua 5.4)
Diffstat (limited to 'util')
-rw-r--r--util/async.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/async.lua b/util/async.lua
index 16dce200..24378d8c 100644
--- a/util/async.lua
+++ b/util/async.lua
@@ -53,7 +53,7 @@ local function runner_continue(thread)
return false;
end
call_watcher(runner, "error", debug.traceback(thread, err));
- runner.state, runner.thread = "ready", nil;
+ runner.state = "ready";
return runner:run();
elseif state == "ready" then
-- If state is 'ready', it is our responsibility to update runner.state from 'waiting'.
@@ -159,6 +159,10 @@ function runner_mt:run(input)
local q, thread = self.queue, self.thread;
if not thread or coroutine.status(thread) == "dead" then
+ --luacheck: ignore 143/coroutine
+ if coroutine.close then
+ coroutine.close(thread);
+ end
self:log("debug", "creating new coroutine");
-- Create a new coroutine for this runner
thread = runner_create_thread(self.func, self);