Changeset

7625:6afafd6d4ef0

net.server_epoll: Move management of fd registry to :setflags
author Kim Alvefur <zash@zash.se>
date Mon, 22 Aug 2016 17:19:49 +0200
parents 7624:23fb3a084956
children 7626:e56343d50293
files net/server_epoll.lua
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Mon Aug 22 17:13:39 2016 +0200
+++ b/net/server_epoll.lua	Mon Aug 22 17:19:49 2016 +0200
@@ -263,6 +263,11 @@
 --	log("debug", "epoll_ctl(%q, %d, %q) -> %s" .. (err and ", %q" or ""),
 --		op, fd, flags or "", tostring(ok), err);
 	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;
 	return true;
 end
@@ -367,7 +372,6 @@
 	self.destroy = noop;
 	self.close = noop;
 	self.on = noop;
-	fds[self:getfd()] = nil;
 	self.conn:close();
 	self.conn = nil;
 end
@@ -455,8 +459,6 @@
 	if client.getsockname then
 		conn.sockname, conn.sockport = client:getsockname();
 	end
-
-	fds[conn:getfd()] = conn;
 	return conn;
 end
 
@@ -528,7 +530,6 @@
 		sockport = port;
 	}, interface_mt);
 	server:setflags(true, false);
-	fds[server:getfd()] = server;
 	return server;
 end