aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_c2s.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-04-14 16:02:47 +0200
committerKim Alvefur <zash@zash.se>2021-04-14 16:02:47 +0200
commit21fa25b27b77a10ec6547adc2c16f66c48f1eb7f (patch)
treed45d5b4f50a0045a1d67d3b7613f3eca5fac94e0 /plugins/mod_c2s.lua
parenta4a008e046e060eb3d0d697b2a1445a62120d91d (diff)
downloadprosody-21fa25b27b77a10ec6547adc2c16f66c48f1eb7f.tar.gz
prosody-21fa25b27b77a10ec6547adc2c16f66c48f1eb7f.zip
mod_c2s: Fix traceback if session was destroyed while opening stream (thanks Ge0rG)
Could happen with the 'opportunistic_writes' setting, since then the stream opening is written directly to the socket, which can in turn trigger session destruction if the socket somehow got closed just after the other sent their stream header. Error happens later when it tries to `hosts[session.host == nil].events`
Diffstat (limited to 'plugins/mod_c2s.lua')
-rw-r--r--plugins/mod_c2s.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index fc838c0d..a222f939 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -92,6 +92,9 @@ function stream_callbacks._streamopened(session, attr)
session:open_stream(host, attr.from);
+ -- Opening the stream can cause the stream to be closed
+ if session.destroyed then return end
+
(session.log or log)("debug", "Sent reply <stream:stream> to client");
session.notopen = nil;