Comparison

net/server_epoll.lua @ 12515:76c1725f4467

net.server_epoll: Add option to defer accept() until data available This is a Linux(?) socket option that delays the accept signal until there is data available to read. E.g. with HTTP this might mean that a whole request can be handled without going back trough another turn of the main loop, and an initial client <stream> can be responded to. This may have effects on latency and resource use, as the server does not need to allocate resources until really needed.
author Kim Alvefur <zash@zash.se>
date Sun, 15 May 2022 22:41:17 +0200
parent 12514:194469fb46f9
child 12542:5ec9d6913162
comparison
equal deleted inserted replaced
12514:194469fb46f9 12515:76c1725f4467
93 --- How long to wait after getting the shutdown signal before forcefully tearing down every socket 93 --- How long to wait after getting the shutdown signal before forcefully tearing down every socket
94 shutdown_deadline = 5; 94 shutdown_deadline = 5;
95 95
96 -- TCP Fast Open 96 -- TCP Fast Open
97 tcp_fastopen = false; 97 tcp_fastopen = false;
98
99 -- Defer accept until incoming data is available
100 tcp_defer_accept = false;
98 }}; 101 }};
99 local cfg = default_config.__index; 102 local cfg = default_config.__index;
100 103
101 local fds = createtable(10, 0); -- FD -> conn 104 local fds = createtable(10, 0); -- FD -> conn
102 105
909 log = logger.init(("serv%s"):format(new_id())); 912 log = logger.init(("serv%s"):format(new_id()));
910 }, interface_mt); 913 }, interface_mt);
911 server:debug("Server %s created", server); 914 server:debug("Server %s created", server);
912 if cfg.tcp_fastopen then 915 if cfg.tcp_fastopen then
913 server:setoption("tcp-fastopen", cfg.tcp_fastopen); 916 server:setoption("tcp-fastopen", cfg.tcp_fastopen);
917 end
918 if type(cfg.tcp_defer_accept) == "number" then
919 server:setoption("tcp-defer-accept", cfg.tcp_defer_accept);
914 end 920 end
915 server:add(true, false); 921 server:add(true, false);
916 return server; 922 return server;
917 end 923 end
918 924