diff options
author | Matthew Wild <mwild1@gmail.com> | 2020-06-14 08:49:32 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2020-06-14 08:49:32 +0100 |
commit | cdfa305a67507d6e7f36a943c2bb599359a54059 (patch) | |
tree | d181a798c4ea2545f6d0fd5e2b4abfc4baaa7f02 /util/async.lua | |
parent | 2861bb873a547ef5c1655fa3fa72c98a2af7411f (diff) | |
download | prosody-cdfa305a67507d6e7f36a943c2bb599359a54059.tar.gz prosody-cdfa305a67507d6e7f36a943c2bb599359a54059.zip |
util.async: Call coroutine.close() on dead threads (Lua 5.4)
Diffstat (limited to 'util/async.lua')
-rw-r--r-- | util/async.lua | 6 |
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); |