Diff

net/server_epoll.lua @ 9383:3260902a5b22

net.server_epoll: Factor out IP/port detection into its own method
author Kim Alvefur <zash@zash.se>
date Wed, 26 Sep 2018 13:53:18 +0200
parent 9382:31a2be28729c
child 9384:5c8006ce8cb8
line wrap: on
line diff
--- a/net/server_epoll.lua	Wed Sep 26 13:52:10 2018 +0200
+++ b/net/server_epoll.lua	Wed Sep 26 13:53:18 2018 +0200
@@ -501,15 +501,20 @@
 		tls_ctx = tls_ctx;
 	}, interface_mt);
 
-	local ok, peername, peerport = pcall(client.getpeername, client);
+	conn:updatenames();
+	return conn;
+end
+
+function interface:updatenames()
+	local conn = self.conn;
+	local ok, peername, peerport = pcall(conn.getpeername, conn);
 	if ok then
-		conn.peername, conn.peerport = peername, peerport;
+		self.peername, self.peerport = peername, peerport;
 	end
-	local ok, sockname, sockport = pcall(client.getsockname, client);
+	local ok, sockname, sockport = pcall(conn.getsockname, conn);
 	if ok then
-		conn.sockname, conn.sockport = sockname, sockport;
+		self.sockname, self.sockport = sockname, sockport;
 	end
-	return conn;
 end
 
 -- A server interface has new incoming connections waiting