util.timer: When using libevent hold onto the event handle to stop it being collected...
authorMatthew Wild <mwild1@gmail.com>
Wed, 7 Apr 2010 20:00:20 +0000 (21:00 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 7 Apr 2010 20:00:20 +0000 (21:00 +0100)
util/timer.lua

index c6bd2748ec20ec0a3e40ac385c46daa8fe91662a..fa1dd7c54cadde12e4bac4aa8a23304ba167bc96 100644 (file)
@@ -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