aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-07-08 12:29:50 +0200
committerKim Alvefur <zash@zash.se>2021-07-08 12:29:50 +0200
commit575b997d1dd13d4295e5bc2f612f8f639c5d9a60 (patch)
tree33617d7b049d804958e91765e1bb4392eec1cff1
parent11017d1130b99b5d0979cf8393ebc2446bea82af (diff)
downloadprosody-575b997d1dd13d4295e5bc2f612f8f639c5d9a60.tar.gz
prosody-575b997d1dd13d4295e5bc2f612f8f639c5d9a60.zip
net.server_epoll: Add support for TCP Fast Open
Requires a patch to LuaSocket adding this socket option, https://github.com/lunarmodules/luasocket/pull/378 sysctl tweaks net.ipv4.tcp_fastopen=3 net.ipv4.tcp_fastopen_blackhole_timeout_sec = 0 net.ipv4.tcp_fastopen_key=$(</proc/sys/kernel/random/uuid) Disabled by default since it an advanced performance tweak unlikely to be needed by most servers.
-rw-r--r--CHANGES1
-rw-r--r--net/server_epoll.lua9
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 5b37d729..f47dc1a9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,7 @@ TRUNK
- Honour 'weight' parameter during SRV record selection
- Support for RFC 8305 "Happy Eyeballs" to improve IPv4/IPv6 connectivity
+- Support for TCP Fast Open in server_epoll (pending LuaSocket support)
0.12.0
======
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 8e75e072..07fb6dd9 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -92,6 +92,9 @@ local default_config = { __index = {
--- How long to wait after getting the shutdown signal before forcefully tearing down every socket
shutdown_deadline = 5;
+
+ -- TCP Fast Open
+ tcp_fastopen = false;
}};
local cfg = default_config.__index;
@@ -906,6 +909,9 @@ local function wrapserver(conn, addr, port, listeners, config)
log = logger.init(("serv%s"):format(new_id()));
}, interface_mt);
server:debug("Server %s created", server);
+ if cfg.tcp_fastopen then
+ server:setoption("tcp-fastopen", cfg.tcp_fastopen);
+ end
server:add(true, false);
return server;
end
@@ -962,6 +968,9 @@ local function addclient(addr, port, listeners, read_size, tls_ctx, typ, extra)
if not conn then return conn, err; end
local ok, err = conn:settimeout(0);
if not ok then return ok, err; end
+ if cfg.tcp_fastopen then
+ pcall(conn.setoption, conn, "tcp-fastopen-connect", 1);
+ end
local ok, err = conn:setpeername(addr, port);
if not ok and err ~= "timeout" then return ok, err; end
local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx, extra)