Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11659:00295a8e5bcf
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 08 Jul 2021 17:52:59 +0200 |
parent | 11658:36942fa001b4 |
child | 11660:68f0196ece2a |
comparison
equal
deleted
inserted
replaced
11658:36942fa001b4 | 11659:00295a8e5bcf |
---|---|
560 self.ondrain = nil; | 560 self.ondrain = nil; |
561 end | 561 end |
562 self.onwritable = interface.tlshandshake; | 562 self.onwritable = interface.tlshandshake; |
563 self.onreadable = interface.tlshandshake; | 563 self.onreadable = interface.tlshandshake; |
564 self:set(true, true); | 564 self:set(true, true); |
565 self:setreadtimeout(cfg.ssl_handshake_timeout); | |
566 self:setwritetimeout(cfg.ssl_handshake_timeout); | |
565 self:debug("Prepared to start TLS"); | 567 self:debug("Prepared to start TLS"); |
566 end | 568 end |
567 end | 569 end |
568 | 570 |
569 function interface:tlshandshake() | 571 function interface:tlshandshake() |
689 self:pausefor(cfg.accept_retry_interval); | 691 self:pausefor(cfg.accept_retry_interval); |
690 return; | 692 return; |
691 end | 693 end |
692 local client = wrapsocket(conn, self, nil, self.listeners); | 694 local client = wrapsocket(conn, self, nil, self.listeners); |
693 client:debug("New connection %s on server %s", client, self); | 695 client:debug("New connection %s on server %s", client, self); |
694 client:init(); | |
695 if self.tls_direct then | 696 if self.tls_direct then |
697 client:add(true, true); | |
696 client:starttls(self.tls_ctx); | 698 client:starttls(self.tls_ctx); |
697 else | 699 else |
700 client:add(true, false); | |
701 client:setreadtimeout(); | |
698 client:onconnect(); | 702 client:onconnect(); |
699 end | 703 end |
700 end | 704 end |
701 | 705 |
702 -- Initialization | 706 -- Initialization for outgoing connections |
703 function interface:init() | 707 function interface:init() |
704 self:setwritetimeout(cfg.connect_timeout); | 708 self:setwritetimeout(cfg.connect_timeout); |
705 return self:add(true, true); | 709 return self:add(true, true); |
706 end | 710 end |
707 | 711 |