aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-26 13:53:18 +0200
committerKim Alvefur <zash@zash.se>2018-09-26 13:53:18 +0200
commit47963b59da90be2d851ae873f3d5ba8796f786b9 (patch)
tree1ddc8cd337853b913b5c2d9610b23f686c79600e
parent4691dc6bef42c073b17c4581c59ada803f57a7f7 (diff)
downloadprosody-47963b59da90be2d851ae873f3d5ba8796f786b9.tar.gz
prosody-47963b59da90be2d851ae873f3d5ba8796f786b9.zip
net.server_epoll: Factor out IP/port detection into its own method
-rw-r--r--net/server_epoll.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index cd91fce0..9751fa45 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -501,15 +501,20 @@ local function wrapsocket(client, server, read_size, listeners, tls_ctx) -- luas
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