Changeset

8408:b751bee6a829

util.async: Fix thread check to work correctly in Lua 5.2 coroutine.running() now returns the main thread and a boolean true if called from the main thread, as opposed to nil in 5.1
author Kim Alvefur <zash@zash.se>
date Tue, 21 Nov 2017 21:48:43 +0100
parents 8407:f652e1ea2f69
children 8410:54ff1f91e4db
files util/async.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/async.lua	Tue Nov 21 21:48:14 2017 +0100
+++ b/util/async.lua	Tue Nov 21 21:48:43 2017 +0100
@@ -1,8 +1,8 @@
 local log = require "util.logger".init("util.async");
 
 local function checkthread()
-	local thread = coroutine.running();
-	if not thread then
+	local thread, main = coroutine.running();
+	if not thread or main then
 		error("Not running in an async context, see https://prosody.im/doc/developers/util/async");
 	end
 	return thread;