aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-04-07 21:00:20 +0100
committerMatthew Wild <mwild1@gmail.com>2010-04-07 21:00:20 +0100
commit90116b3c354d4c48b65e1fb66074e3329bbf4fe0 (patch)
tree5ee8606e070cfdad53b790bd1cd478031650379b /util
parent89e9f18d2ac62feb42a56a87ef0836a886da5d76 (diff)
downloadprosody-90116b3c354d4c48b65e1fb66074e3329bbf4fe0.tar.gz
prosody-90116b3c354d4c48b65e1fb66074e3329bbf4fe0.zip
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.
Diffstat (limited to 'util')
-rw-r--r--util/timer.lua5
1 files changed, 3 insertions, 2 deletions
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