diff options
author | Kim Alvefur <zash@zash.se> | 2017-01-06 17:01:48 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-01-06 17:01:48 +0100 |
commit | ea5d14cb81bd618da08e46fc4a314379d8df46ca (patch) | |
tree | 9a93220adf36ce32c66c64cf132bc5ffb8b9fe46 /net/server_epoll.lua | |
parent | d58c574d4d4c89b2a056f10d99973a19cde34ec2 (diff) | |
download | prosody-ea5d14cb81bd618da08e46fc4a314379d8df46ca.tar.gz prosody-ea5d14cb81bd618da08e46fc4a314379d8df46ca.zip |
net.server_epoll: Reuse interface metatable for event compat layer
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r-- | net/server_epoll.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 0f340560..086c8dfc 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -671,23 +671,23 @@ return { local function onevent(self) local ret = self:callback(); if ret == -1 then - epoll.ctl("del", fd); + self:setflags(false, false); elseif ret then - epoll.ctl("mod", fd, mode); + self:setflags(mode == "r" or mode == "rw", mode == "w" or mode == "rw"); end end - local conn = { + local conn = setmetatable({ + getfd = function () return fd; end; callback = callback; onreadable = onevent; onwriteable = onevent; - close = function () + close = function (self) + self:setflags(false, false); fds[fd] = nil; - return epoll.ctl("del", fd); end; - }; - fds[fd] = conn; - local ok, err = epoll.ctl("add", fd, mode or "r"); + }, interface_mt); + local ok, err = conn:setflags(mode == "r" or mode == "rw", mode == "w" or mode == "rw"); if not ok then return ok, err; end return conn; end; |