# HG changeset patch # User Kim Alvefur # Date 1471532834 -7200 # Node ID 335b5ce060620873c04087c756ccd91bd6527916 # Parent cd34aa6b1632a905b0b14575deb781deeed0c35e net.server_epoll: TLS handshake timeout diff -r cd34aa6b1632 -r 335b5ce06062 net/server_epoll.lua --- a/net/server_epoll.lua Thu Aug 18 16:59:31 2016 +0200 +++ b/net/server_epoll.lua Thu Aug 18 17:07:14 2016 +0200 @@ -30,6 +30,7 @@ tcp_backlog = 128; accept_retry_interval = 10; read_retry_delay = 1e-06; + handshake_timeout = 60; }; local fds = createtable(10, 0); -- FD -> conn @@ -385,10 +386,13 @@ self.onwriteable = interface.tlshandskake; self.onreadable = interface.tlshandskake; self:setflags(true, true); + self:setwritetimeout(cfg.handshake_timeout); end end function interface:tlshandskake() + self:setwritetimeout(false); + self:setreadtimeout(false); local ok, err = self.conn:dohandshake(); if ok then log("debug", "TLS handshake on %s complete", tostring(self)); @@ -406,12 +410,10 @@ elseif err == "wantread" then log("debug", "TLS handshake on %s to wait until readable", tostring(self)); self:setflags(true, false); - self:setwritetimeout(false); self:setreadtimeout(cfg.handshake_timeout); elseif err == "wantwrite" then log("debug", "TLS handshake on %s to wait until writable", tostring(self)); self:setflags(false, true); - self:setreadtimeout(false); self:setwritetimeout(cfg.handshake_timeout); else log("debug", "TLS handshake error on %s: %s", tostring(self), err);