diff options
author | Kim Alvefur <zash@zash.se> | 2021-07-13 14:55:21 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-07-13 14:55:21 +0200 |
commit | 1877068b3d5962a3b00868203fcc579104065e59 (patch) | |
tree | 4fee483d49b7303177e352d1621e1e293cfc61b1 /net | |
parent | 123a7b70799c0ec3f773a7422e304ca4940b3ae3 (diff) | |
download | prosody-1877068b3d5962a3b00868203fcc579104065e59.tar.gz prosody-1877068b3d5962a3b00868203fcc579104065e59.zip |
net.server_epoll: Refactor immediate TLS handshake start
Diffstat (limited to 'net')
-rw-r--r-- | net/server_epoll.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index ce69abb1..2dfd44e8 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -570,7 +570,7 @@ function interface:starttls(tls_ctx) end end -function interface:inittls(tls_ctx) +function interface:inittls(tls_ctx, now) if self._tls then return end if tls_ctx then self.tls_ctx = tls_ctx; end self._tls = true; @@ -612,6 +612,9 @@ function interface:inittls(tls_ctx) self.ondrain = nil; self.onwritable = interface.tlshandshake; self.onreadable = interface.tlshandshake; + if now then + return self:tlshandshake() + end self:setreadtimeout(cfg.ssl_handshake_timeout); self:setwritetimeout(cfg.ssl_handshake_timeout); self:set(true, true); @@ -701,11 +704,7 @@ function interface:onacceptable() client:debug("New connection %s on server %s", client, self); if self.tls_direct then client:add(true, true); - if client:inittls(self.tls_ctx) then - client:setreadtimeout(cfg.ssl_handshake_timeout); - client:setwritetimeout(cfg.ssl_handshake_timeout); - client:tlshandshake(); - end + client:inittls(self.tls_ctx, true); else client:add(true, false); client:onconnect(); |