Comparison

net/server_epoll.lua @ 11811:ae43166fe931 0.11

net.server_epoll: Add a hard deadline on shutdown to extra-fix #1670 Should ensure shutdown even if sockets somehow take a very long to get closed.
author Kim Alvefur <zash@zash.se>
date Mon, 20 Sep 2021 14:38:08 +0200
parent 11810:fe0cdbad19c3
child 11812:42e98179c034
child 12084:59557bc3c4b8
comparison
equal deleted inserted replaced
11810:fe0cdbad19c3 11811:ae43166fe931
56 ssl_handshake_timeout = 60; 56 ssl_handshake_timeout = 60;
57 57
58 -- Maximum and minimum amount of time to sleep waiting for events (adjusted for pending timers) 58 -- Maximum and minimum amount of time to sleep waiting for events (adjusted for pending timers)
59 max_wait = 86400; 59 max_wait = 86400;
60 min_wait = 1e-06; 60 min_wait = 1e-06;
61
62 --- How long to wait after getting the shutdown signal before forcefully tearing down every socket
63 shutdown_deadline = 5;
61 }}; 64 }};
62 local cfg = default_config.__index; 65 local cfg = default_config.__index;
63 66
64 local fds = createtable(10, 0); -- FD -> conn 67 local fds = createtable(10, 0); -- FD -> conn
65 68
747 if quitting then 750 if quitting then
748 closeall(); 751 closeall();
749 return 1; 752 return 1;
750 end 753 end
751 end); 754 end);
755 if cfg.shutdown_deadline then
756 addtimer(cfg.shutdown_deadline, function ()
757 if quitting then
758 for fd, conn in pairs(fds) do -- luacheck: ignore 213/fd
759 conn:destroy();
760 end
761 end
762 end);
763 end
752 else 764 else
753 quitting = nil; 765 quitting = nil;
754 end 766 end
755 end 767 end
756 768