# HG changeset patch # User Kim Alvefur # Date 1623880380 -7200 # Node ID 6dcc45a2e3bc32216c4192abe9b4149bf5a43a6c # Parent b2610460d9ab91ffb881e24bd6c9edd6d5f8b141 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. diff -r b2610460d9ab -r 6dcc45a2e3bc plugins/mod_s2s.lua --- a/plugins/mod_s2s.lua Wed Jun 16 00:00:17 2021 +0200 +++ b/plugins/mod_s2s.lua Wed Jun 16 23:53:00 2021 +0200 @@ -461,6 +461,11 @@ 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");