diff options
author | Kim Alvefur <zash@zash.se> | 2021-07-08 17:52:59 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-07-08 17:52:59 +0200 |
commit | 852e44959d04b56cbf3c761b1ab5e0547ae05cc7 (patch) | |
tree | b73eac8c0c1e42ce2ade269919d5d9c5537df92f /net | |
parent | 532fbe06878da9f0b10816be662f6aa7463b8f84 (diff) | |
download | prosody-852e44959d04b56cbf3c761b1ab5e0547ae05cc7.tar.gz prosody-852e44959d04b56cbf3c761b1ab5e0547ae05cc7.zip |
net.server_epoll: Separate handling of new incoming and outgoing connections
The :init method is more suited for new outgoing connections, which is
why it uses the connect_timeout setting.
Depending on whether a newly accepted connection is to a Direct TLS port
or not, it should be handled differently, and was already. The :starttls
method sets up timeouts on its own, so the one set in :init was not needed.
Newly accepted plain TCP connections don't need a write timeout set, a
read timeout is enough.
Diffstat (limited to 'net')
-rw-r--r-- | net/server_epoll.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 6618c204..d4a08d3d 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -562,6 +562,8 @@ function interface:starttls(tls_ctx) self.onwritable = interface.tlshandshake; self.onreadable = interface.tlshandshake; self:set(true, true); + self:setreadtimeout(cfg.ssl_handshake_timeout); + self:setwritetimeout(cfg.ssl_handshake_timeout); self:debug("Prepared to start TLS"); end end @@ -691,15 +693,17 @@ function interface:onacceptable() end local client = wrapsocket(conn, self, nil, self.listeners); client:debug("New connection %s on server %s", client, self); - client:init(); if self.tls_direct then + client:add(true, true); client:starttls(self.tls_ctx); else + client:add(true, false); + client:setreadtimeout(); client:onconnect(); end end --- Initialization +-- Initialization for outgoing connections function interface:init() self:setwritetimeout(cfg.connect_timeout); return self:add(true, true); |