# HG changeset patch # User Jonas Schäfer # Date 1648891137 -7200 # Node ID 988a3a7e1f353558112593a91a143a56de47f15e # Parent b193f8a2737edccf4fb3249e8413ae9f09bf5211 mod_tls: tell network backend to stop reading while preparing TLS diff -r b193f8a2737e -r 988a3a7e1f35 plugins/mod_tls.lua --- a/plugins/mod_tls.lua Fri Sep 17 21:18:30 2021 +0200 +++ b/plugins/mod_tls.lua Sat Apr 02 11:18:57 2022 +0200 @@ -129,6 +129,13 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) local origin = event.origin; if can_do_tls(origin) then + if origin.conn.block_reads then + -- we need to ensure that no data is read anymore, otherwise we could end up in a situation where + -- is sent and the socket receives the TLS handshake (and passes the data to lua) before + -- it is asked to initiate TLS + -- (not with the classical single-threaded server backends) + origin.conn:block_reads() + end (origin.sends2s or origin.send)(starttls_proceed); if origin.destroyed then return end origin:reset_stream();