From f55f6be0ff08fdbc44f0b88cc759885eb1296055 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 16 Jun 2021 23:53:00 +0200 Subject: mod_s2s: Bail if connection is destroyed after attempting to open stream Fixes "attempt to compare number with nil" because `session.version` has been cleared by s2smanager.destroy_session. This can happen with the server_epoll setting opportunistic_writes enabled, which means that it can notice that the connection failed at this point, after which it triggers the whole chain of events that leads to session destruction and "cleaning" most of the session fields. --- plugins/mod_s2s.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/mod_s2s.lua') diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua index 19c94b2d..86bb0795 100644 --- a/plugins/mod_s2s.lua +++ b/plugins/mod_s2s.lua @@ -461,6 +461,11 @@ function stream_callbacks._streamopened(session, attr) end session:open_stream(session.to_host, session.from_host) + if session.destroyed then + -- sending the stream opening could have failed during an opportunistic write + return + end + session.notopen = nil; if session.version >= 1.0 then local features = st.stanza("stream:features"); -- cgit v1.2.3