aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
commite6ab467ef9f3f98a3f041ab6a525321acd2707ee (patch)
tree04d093edf8ae45cd7be94face597cfc971e4c864 /net
parent3ce10e3af3c6d5a7447e01110f0a375f9028d953 (diff)
downloadprosody-e6ab467ef9f3f98a3f041ab6a525321acd2707ee.tar.gz
prosody-e6ab467ef9f3f98a3f041ab6a525321acd2707ee.zip
net.cqueues: Add workaround for luaevent callback getting collected
Diffstat (limited to 'net')
-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();