diff options
author | Kim Alvefur <zash@zash.se> | 2018-09-26 13:53:18 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-09-26 13:53:18 +0200 |
commit | 83f334145242d180bd1578566de68dc16a956dff (patch) | |
tree | 1ddc8cd337853b913b5c2d9610b23f686c79600e | |
parent | 6ba93205b0efeffaf73f55624bb920bd31c02eab (diff) | |
download | prosody-83f334145242d180bd1578566de68dc16a956dff.tar.gz prosody-83f334145242d180bd1578566de68dc16a956dff.zip |
net.server_epoll: Factor out IP/port detection into its own method
-rw-r--r-- | net/server_epoll.lua | 15 |
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 |