Comparison

net/server_epoll.lua @ 11687:153d2fdd97d3

net.server_epoll: Add way to enable TCP keeplives on all connections In case one wishes to enable this for all connections, not just c2s (not Direct TLS ones, because LuaSec) and s2s. Unclear what use these are, since they kick in after 2 hours of idle time.
author Kim Alvefur <zash@zash.se>
date Wed, 14 Jul 2021 22:09:39 +0200
parent 11686:f4c3dcc907d8
child 11688:3fc564f7441b
comparison
equal deleted inserted replaced
11686:f4c3dcc907d8 11687:153d2fdd97d3
78 -- Or disable protection (like server_select) for potential performance gains 78 -- Or disable protection (like server_select) for potential performance gains
79 protect_listeners = true; 79 protect_listeners = true;
80 80
81 -- Attempt writes instantly 81 -- Attempt writes instantly
82 opportunistic_writes = false; 82 opportunistic_writes = false;
83
84 -- TCP Keepalives
85 tcp_keepalive = false; -- boolean | number
83 }}; 86 }};
84 local cfg = default_config.__index; 87 local cfg = default_config.__index;
85 88
86 local fds = createtable(10, 0); -- FD -> conn 89 local fds = createtable(10, 0); -- FD -> conn
87 90
725 self:setwritetimeout(cfg.connect_timeout); 728 self:setwritetimeout(cfg.connect_timeout);
726 self:defaultoptions(); 729 self:defaultoptions();
727 return self:add(true, true); 730 return self:add(true, true);
728 end 731 end
729 732
730 -- luacheck: ignore 212/self
731 function interface:defaultoptions() 733 function interface:defaultoptions()
734 if cfg.tcp_keepalive then
735 self:setoption("keepalive", true);
736 end
732 end 737 end
733 738
734 function interface:pause() 739 function interface:pause()
735 self:noise("Pause reading"); 740 self:noise("Pause reading");
736 return self:set(false); 741 return self:set(false);