mod_csi_simple: Unlock writes after event, to allow things to be queued
authorKim Alvefur <zash@zash.se>
Tue, 16 Nov 2021 13:37:18 +0100
changeset 11917 75d69e4c54a2
parent 11916 037b2c019f58
child 11918 8f7946ce7d66
mod_csi_simple: Unlock writes after event, to allow things to be queued E.g. mod_smacks could queue an <r>, which would be more likely to be included in the same write and TCP segment as the previously buffered data, reducing syscalls and network packets needing to be sent.
plugins/mod_csi_simple.lua
--- a/plugins/mod_csi_simple.lua	Tue Nov 16 12:57:23 2021 +0000
+++ b/plugins/mod_csi_simple.lua	Tue Nov 16 13:37:18 2021 +0100
@@ -124,9 +124,9 @@
 		end
 		flush_reasons:with_labels(why or "important"):add(1);
 		session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter);
-		session.conn:resume_writes();
 		session.state = "flushing";
 		module:fire_event("csi-flushing", { session = session });
+		session.conn:resume_writes();
 	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))