mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
net.cqueues: Add workaround for luaevent callback getting collected
This commit is contained in:
parent
3ce10e3af3
commit
e6ab467ef9
1 changed files with 5 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue