util.timer: When using libevent hold onto the event handle to stop it being collected (and the timer stopping). Fixes BOSH ghosts, thanks Flo, niekie, waqas.

Wed, 07 Apr 2010 21:00:20 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 07 Apr 2010 21:00:20 +0100
changeset 2964
49b5c87d2fa0
parent 2961
db3c0ecce3f4
child 2965
0fe9cfaeaed7
child 2968
fdd049a4e551

util.timer: When using libevent hold onto the event handle to stop it being collected (and the timer stopping). Fixes BOSH ghosts, thanks Flo, niekie, waqas.

util/timer.lua file | annotate | diff | comparison | revisions
--- a/util/timer.lua	Sat Apr 03 23:09:11 2010 +0100
+++ b/util/timer.lua	Wed Apr 07 21:00:20 2010 +0100
@@ -55,11 +55,12 @@
 else
 	local EVENT_LEAVE = (event.core and event.core.LEAVE) or -1;
 	function _add_task(delay, func)
-		event_base:addevent(nil, 0, function ()
+		local event_handle;
+		event_handle = event_base:addevent(nil, 0, function ()
 			local ret = func();
 			if ret then
 				return 0, ret;
-			else
+			elseif event_handle then
 				return EVENT_LEAVE;
 			end
 		end

mercurial