net.server_epoll: Support setting keepalive idle time
authorKim Alvefur <zash@zash.se>
Wed, 14 Jul 2021 22:13:30 +0200
changeset 11692 3fc564f7441b
parent 11691 153d2fdd97d3
child 11693 f9f6e82fb572
net.server_epoll: Support setting keepalive idle time Activated by setting config.tcp_keepalive to a number, in seconds. Defaults to 2h. Depends on LuaSocket support for this option.
net/server_epoll.lua
--- a/net/server_epoll.lua	Wed Jul 14 22:09:39 2021 +0200
+++ b/net/server_epoll.lua	Wed Jul 14 22:13:30 2021 +0200
@@ -733,6 +733,9 @@
 function interface:defaultoptions()
 	if cfg.tcp_keepalive then
 		self:setoption("keepalive", true);
+		if type(cfg.tcp_keepalive) == "number" then
+			self:setoption("tcp-keepidle", cfg.tcp_keepalive);
+		end
 	end
 end