net.server_epoll: Move management of fd registry to :setflags

This commit is contained in:
Kim Alvefur 2016-08-22 17:19:49 +02:00
parent e0bc7dd70f
commit e98fe5eb04

View file

@ -263,6 +263,11 @@ function interface:setflags(r, w)
-- log("debug", "epoll_ctl(%q, %d, %q) -> %s" .. (err and ", %q" or ""), -- log("debug", "epoll_ctl(%q, %d, %q) -> %s" .. (err and ", %q" or ""),
-- op, fd, flags or "", tostring(ok), err); -- op, fd, flags or "", tostring(ok), err);
if not ok then return ok, err end if not ok then return ok, err end
if op == "add" then
fds[fd] = self;
elseif op == "del" then
fds[fd] = nil;
end
self._flags = flags; self._flags = flags;
return true; return true;
end end
@ -367,7 +372,6 @@ function interface:destroy()
self.destroy = noop; self.destroy = noop;
self.close = noop; self.close = noop;
self.on = noop; self.on = noop;
fds[self:getfd()] = nil;
self.conn:close(); self.conn:close();
self.conn = nil; self.conn = nil;
end end
@ -455,8 +459,6 @@ local function wrapsocket(client, server, pattern, listeners, tls) -- luasocket
if client.getsockname then if client.getsockname then
conn.sockname, conn.sockport = client:getsockname(); conn.sockname, conn.sockport = client:getsockname();
end end
fds[conn:getfd()] = conn;
return conn; return conn;
end end
@ -528,7 +530,6 @@ local function addserver(addr, port, listeners, pattern, tls)
sockport = port; sockport = port;
}, interface_mt); }, interface_mt);
server:setflags(true, false); server:setflags(true, false);
fds[server:getfd()] = server;
return server; return server;
end end