Wed, 07 Apr 2010 21:00:20 +0100
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