mod_c2s: Fix traceback if session was destroyed while opening stream (thanks Ge0rG)
authorKim Alvefur <zash@zash.se>
Wed, 14 Apr 2021 16:02:47 +0200
changeset 11521 f7275c2c58fa
parent 11520 83822be7704d
child 11522 3f1a865e9419
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`
plugins/mod_c2s.lua
--- a/plugins/mod_c2s.lua	Wed Apr 14 15:21:13 2021 +0200
+++ b/plugins/mod_c2s.lua	Wed Apr 14 16:02:47 2021 +0200
@@ -92,6 +92,9 @@
 
 	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;