From 90116b3c354d4c48b65e1fb66074e3329bbf4fe0 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 7 Apr 2010 21:00:20 +0100 Subject: 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'util/timer.lua') diff --git a/util/timer.lua b/util/timer.lua index c6bd2748..fa1dd7c5 100644 --- a/util/timer.lua +++ b/util/timer.lua @@ -55,11 +55,12 @@ if not event then 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 -- cgit v1.2.3