Diff

plugins/mod_csi_simple.lua @ 10302:4c53e58d2468

mod_csi_simple: Try not to flush buffer while already flushing it Reduces log noice
author Kim Alvefur <zash@zash.se>
date Sat, 05 Oct 2019 16:50:41 +0200
parent 10277:45a58127a3e5
child 10303:c434bff22b14
line wrap: on
line diff
--- a/plugins/mod_csi_simple.lua	Sat Oct 05 16:21:41 2019 +0200
+++ b/plugins/mod_csi_simple.lua	Sat Oct 05 16:50:41 2019 +0200
@@ -75,6 +75,10 @@
 end
 
 local function flush_buffer(data, session)
+	if session.csi_flushing then
+		return data;
+	end
+	session.csi_flushing = true;
 	session.log("debug", "Client sent something, flushing buffer once (queue size is %d)", session.csi_counter);
 	session.conn:resume_writes();
 	return data;
@@ -92,6 +96,7 @@
 
 function disable_optimizations(session)
 	if session.conn and session.conn.resume_writes then
+		session.csi_flushing = nil;
 		filters.remove_filter(session, "stanzas/out", manage_buffer);
 		filters.remove_filter(session, "bytes/in", flush_buffer);
 		session.conn:resume_writes();