aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-06-16 23:53:00 +0200
committerKim Alvefur <zash@zash.se>2021-06-16 23:53:00 +0200
commitf55f6be0ff08fdbc44f0b88cc759885eb1296055 (patch)
treecb915e806b9fdfdd170b7525652030bab001feda
parentaa041ffa1060e07be9a02ef6b523623f364f962a (diff)
downloadprosody-f55f6be0ff08fdbc44f0b88cc759885eb1296055.tar.gz
prosody-f55f6be0ff08fdbc44f0b88cc759885eb1296055.zip
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.
-rw-r--r--plugins/mod_s2s.lua5
1 files changed, 5 insertions, 0 deletions
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");