Changeset

11379:5c820553ef82

mod_csi_simple: Set session state to 'flushing' while doing so May be useful for 3rd party modules.
author Kim Alvefur <zash@zash.se>
date Tue, 16 Feb 2021 23:09:51 +0100
parents 11378:b790df8f9448
children 11380:9a1758c5aaa4
files plugins/mod_csi_simple.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua	Mon Feb 15 22:30:28 2021 +0100
+++ b/plugins/mod_csi_simple.lua	Tue Feb 16 23:09:51 2021 +0100
@@ -127,6 +127,7 @@
 		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 @@
 
 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);