Comparison

plugins/mod_csi_simple.lua @ 11913:75d69e4c54a2

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.
author Kim Alvefur <zash@zash.se>
date Tue, 16 Nov 2021 13:37:18 +0100
parent 11834:f54d9abc4e14
child 11914:8f7946ce7d66
comparison
equal deleted inserted replaced
11912:037b2c019f58 11913:75d69e4c54a2
122 session.csi_measure_buffer_hold(); 122 session.csi_measure_buffer_hold();
123 session.csi_measure_buffer_hold = nil; 123 session.csi_measure_buffer_hold = nil;
124 end 124 end
125 flush_reasons:with_labels(why or "important"):add(1); 125 flush_reasons:with_labels(why or "important"):add(1);
126 session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter); 126 session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter);
127 session.conn:resume_writes();
128 session.state = "flushing"; 127 session.state = "flushing";
129 module:fire_event("csi-flushing", { session = session }); 128 module:fire_event("csi-flushing", { session = session });
129 session.conn:resume_writes();
130 else 130 else
131 session.log("debug", "Holding buffer (%s; queue size is %d)", why or "unimportant", session.csi_counter); 131 session.log("debug", "Holding buffer (%s; queue size is %d)", why or "unimportant", session.csi_counter);
132 stanza = with_timestamp(stanza, jid.join(session.username, session.host)) 132 stanza = with_timestamp(stanza, jid.join(session.username, session.host))
133 end 133 end
134 session.csi_counter = ctr + 1; 134 session.csi_counter = ctr + 1;