diff options
author | Kim Alvefur <zash@zash.se> | 2020-06-01 17:19:08 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-06-01 17:19:08 +0200 |
commit | 9708aab9b3b62c87e038f8d33cf64c8d11d53d32 (patch) | |
tree | 3a1620cf420d9dc57435d43d06ee63ff2aea8519 | |
parent | f554caa3ac8cd7c7c8223d121f59947e9f0ded68 (diff) | |
download | prosody-9708aab9b3b62c87e038f8d33cf64c8d11d53d32.tar.gz prosody-9708aab9b3b62c87e038f8d33cf64c8d11d53d32.zip |
net.server_epoll: Add way to start accepting clients on an arbitrary server socket
This adds an escape hatch where things like UNIX sockets can be added.
-rw-r--r-- | net/server_epoll.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index ded42c4d..f4c14e13 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -719,10 +719,7 @@ function interface:onconnect() self:on("connect"); end -local function listen(addr, port, listeners, config) - local conn, err = socket.bind(addr, port, cfg.tcp_backlog); - if not conn then return conn, err; end - conn:settimeout(0); +local function wrapserver(conn, addr, port, listeners, config) local server = setmetatable({ conn = conn; created = realtime(); @@ -741,6 +738,13 @@ local function listen(addr, port, listeners, config) return server; end +local function listen(addr, port, listeners, config) + local conn, err = socket.bind(addr, port, cfg.tcp_backlog); + if not conn then return conn, err; end + conn:settimeout(0); + return wrapserver(conn, addr, port, listeners, config); +end + -- COMPAT local function addserver(addr, port, listeners, read_size, tls_ctx) return listen(addr, port, listeners, { @@ -897,6 +901,7 @@ return { closeall = closeall; setquitting = setquitting; wrapclient = wrapclient; + wrapserver = wrapserver; watchfd = watchfd; link = link; set_config = function (newconfig) |