aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2015-01-06 20:01:59 -0500
committerdaurnimator <quae@daurnimator.com>2015-01-06 20:01:59 -0500
commitf777a56e6634fc54ac9d2f8d9599861af8bb18d5 (patch)
tree04d093edf8ae45cd7be94face597cfc971e4c864
parentdc851debfaea80873071689070ef994c46fb8a02 (diff)
downloadprosody-f777a56e6634fc54ac9d2f8d9599861af8bb18d5.tar.gz
prosody-f777a56e6634fc54ac9d2f8d9599861af8bb18d5.zip
net.cqueues: Add workaround for luaevent callback getting collected
-rw-r--r--net/cqueues.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/cqueues.lua b/net/cqueues.lua
index e82fe4ad..a67e405a 100644
--- a/net/cqueues.lua
+++ b/net/cqueues.lua
@@ -43,7 +43,11 @@ elseif server.event and server.base then -- server_event
cq = cqueues.new();
-- Only need to listen for readable; cqueues handles everything under the hood
local EV_READ = server.event.EV_READ;
- server.base:addevent(cq:pollfd(), EV_READ, function(e)
+ local event_handle;
+ event_handle = server.base:addevent(cq:pollfd(), EV_READ, function(e)
+ -- Need to reference event_handle or this callback will get collected
+ -- This creates a circular reference that can only be broken if event_handle is manually :close()'d
+ local _ = event_handle;
assert(cq:loop(0));
-- Convert a cq timeout to an acceptable timeout for luaevent
local t = cq:timeout();