From dcab373f45c5304aa683db64fc5fa5529e680b23 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 16 Feb 2021 23:09:51 +0100 Subject: mod_csi_simple: Set session state to 'flushing' while doing so May be useful for 3rd party modules. --- plugins/mod_csi_simple.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/mod_csi_simple.lua b/plugins/mod_csi_simple.lua index fed8a8bd..ebe726fe 100644 --- a/plugins/mod_csi_simple.lua +++ b/plugins/mod_csi_simple.lua @@ -127,6 +127,7 @@ local function manage_buffer(stanza, session) flush_reasons[why or "important"](); session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter); session.conn:resume_writes(); + session.state = "flushing"; else session.log("debug", "Holding buffer (%s; queue size is %d)", why or "unimportant", session.csi_counter); stanza = with_timestamp(stanza, jid.join(session.username, session.host)) @@ -188,7 +189,8 @@ end, 1); module:hook("c2s-ondrain", function (event) local session = event.session; - if session.state == "inactive" and session.conn and session.conn.pause_writes then + if (session.state == "flushing" or session.state == "inactive") and session.conn and session.conn.pause_writes then + session.state = "inactive"; session.conn:pause_writes(); session.csi_measure_buffer_hold = measure_buffer_hold(); session.log("debug", "Buffer flushed, resuming inactive mode (queue size was %d)", session.csi_counter); -- cgit v1.2.3