# HG changeset patch # User Matthew Wild # Date 1270670420 -3600 # Node ID 49b5c87d2fa0082c2ad5ee8ab35f2e6cc69d36aa # Parent db3c0ecce3f4192ce5f1b28ec5af16180b6a79f2 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. diff -r db3c0ecce3f4 -r 49b5c87d2fa0 util/timer.lua --- 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