comparison mod_smacks/mod_smacks.lua @ 4537:53ee391ca689

mod_smacks: Fix traceback due to session being destroyed in send() Sending something can cause the OS to notice that the connection is dead and then the connection can be dead at this point. More likely if opportunistic_writes is enabled.
author Kim Alvefur <zash@zash.se>
date Thu, 01 Apr 2021 11:35:26 +0200
parents 8bdb9805bb73
children 4e7aa32f58d9
comparison
equal deleted inserted replaced
4536:8bdb9805bb73 4537:53ee391ca689
179 -- session.log("debug", "*** SMACKS(3) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating)); 179 -- session.log("debug", "*** SMACKS(3) ***: awaiting_ack=%s, hibernating=%s", tostring(session.awaiting_ack), tostring(session.hibernating));
180 -- only request ack if needed and our session is not already hibernated or destroyed 180 -- only request ack if needed and our session is not already hibernated or destroyed
181 if not session.awaiting_ack and not session.hibernating and not session.destroyed then 181 if not session.awaiting_ack and not session.hibernating and not session.destroyed then
182 session.log("debug", "Sending <r> (inside timer, before send) from %s - #queue=%d", reason, #queue); 182 session.log("debug", "Sending <r> (inside timer, before send) from %s - #queue=%d", reason, #queue);
183 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })) 183 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks }))
184 if session.destroyed then return end -- sending something can trigger destruction
184 session.awaiting_ack = true; 185 session.awaiting_ack = true;
185 -- expected_h could be lower than this expression e.g. more stanzas added to the queue meanwhile) 186 -- expected_h could be lower than this expression e.g. more stanzas added to the queue meanwhile)
186 session.last_requested_h = session.last_acknowledged_stanza + #queue; 187 session.last_requested_h = session.last_acknowledged_stanza + #queue;
187 session.log("debug", "Sending <r> (inside timer, after send) from %s - #queue=%d", reason, #queue); 188 session.log("debug", "Sending <r> (inside timer, after send) from %s - #queue=%d", reason, #queue);
188 if not session.delayed_ack_timer then 189 if not session.delayed_ack_timer then