Software /
code /
prosody
Diff
net/server_epoll.lua @ 10861:e12690a37795
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 01 Jun 2020 17:19:08 +0200 |
parent | 10854:472fe13a05f9 |
child | 10982:276f16101d59 |
line wrap: on
line diff
--- a/net/server_epoll.lua Mon Jun 01 16:14:44 2020 +0100 +++ b/net/server_epoll.lua Mon Jun 01 17:19:08 2020 +0200 @@ -719,10 +719,7 @@ 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 @@ 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 @@ closeall = closeall; setquitting = setquitting; wrapclient = wrapclient; + wrapserver = wrapserver; watchfd = watchfd; link = link; set_config = function (newconfig)