Software /
code /
prosody
Comparison
plugins/mod_csi_simple.lua @ 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 |
parent | 11260:08b397c21805 |
child | 11380:9a1758c5aaa4 |
comparison
equal
deleted
inserted
replaced
11378:b790df8f9448 | 11379:5c820553ef82 |
---|---|
125 session.csi_measure_buffer_hold = nil; | 125 session.csi_measure_buffer_hold = nil; |
126 end | 126 end |
127 flush_reasons[why or "important"](); | 127 flush_reasons[why or "important"](); |
128 session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter); | 128 session.log("debug", "Flushing buffer (%s; queue size is %d)", why or "important", session.csi_counter); |
129 session.conn:resume_writes(); | 129 session.conn:resume_writes(); |
130 session.state = "flushing"; | |
130 else | 131 else |
131 session.log("debug", "Holding buffer (%s; queue size is %d)", why or "unimportant", session.csi_counter); | 132 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)) | 133 stanza = with_timestamp(stanza, jid.join(session.username, session.host)) |
133 end | 134 end |
134 session.csi_counter = ctr + 1; | 135 session.csi_counter = ctr + 1; |
186 disable_optimizations(session); | 187 disable_optimizations(session); |
187 end, 1); | 188 end, 1); |
188 | 189 |
189 module:hook("c2s-ondrain", function (event) | 190 module:hook("c2s-ondrain", function (event) |
190 local session = event.session; | 191 local session = event.session; |
191 if session.state == "inactive" and session.conn and session.conn.pause_writes then | 192 if (session.state == "flushing" or session.state == "inactive") and session.conn and session.conn.pause_writes then |
193 session.state = "inactive"; | |
192 session.conn:pause_writes(); | 194 session.conn:pause_writes(); |
193 session.csi_measure_buffer_hold = measure_buffer_hold(); | 195 session.csi_measure_buffer_hold = measure_buffer_hold(); |
194 session.log("debug", "Buffer flushed, resuming inactive mode (queue size was %d)", session.csi_counter); | 196 session.log("debug", "Buffer flushed, resuming inactive mode (queue size was %d)", session.csi_counter); |
195 session.csi_counter = 0; | 197 session.csi_counter = 0; |
196 end | 198 end |