Comparison

plugins/mod_csi_simple.lua @ 13092:bc46cfe7c037

Merge 0.12->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 01 May 2023 22:24:13 +0200
parent 12977:74b9e05af71e
parent 13091:214a679823e8
child 13209:c8d949cf6b09
comparison
equal deleted inserted replaced
13089:41598b7ec543 13092:bc46cfe7c037
164 function enable_optimizations(session) 164 function enable_optimizations(session)
165 if session.conn and session.conn.pause_writes then 165 if session.conn and session.conn.pause_writes then
166 session.conn:pause_writes(); 166 session.conn:pause_writes();
167 session.csi_measure_buffer_hold = measure_buffer_hold(); 167 session.csi_measure_buffer_hold = measure_buffer_hold();
168 session.csi_counter = 0; 168 session.csi_counter = 0;
169 if session.csi_resume then
170 timer.stop(session.csi_resume);
171 session.csi_resume = nil;
172 end
169 filters.add_filter(session, "stanzas/out", manage_buffer); 173 filters.add_filter(session, "stanzas/out", manage_buffer);
170 filters.add_filter(session, "bytes/in", flush_buffer); 174 filters.add_filter(session, "bytes/in", flush_buffer);
171 else 175 else
172 session.log("warn", "Session connection does not support write pausing"); 176 session.log("warn", "Session connection does not support write pausing");
173 end 177 end
175 179
176 function disable_optimizations(session) 180 function disable_optimizations(session)
177 filters.remove_filter(session, "stanzas/out", manage_buffer); 181 filters.remove_filter(session, "stanzas/out", manage_buffer);
178 filters.remove_filter(session, "bytes/in", flush_buffer); 182 filters.remove_filter(session, "bytes/in", flush_buffer);
179 session.csi_counter = nil; 183 session.csi_counter = nil;
184 if session.csi_resume then
185 timer.stop(session.csi_resume);
186 session.csi_resume = nil;
187 end
180 if session.csi_measure_buffer_hold then 188 if session.csi_measure_buffer_hold then
181 session.csi_measure_buffer_hold(); 189 session.csi_measure_buffer_hold();
182 session.csi_measure_buffer_hold = nil; 190 session.csi_measure_buffer_hold = nil;
183 end 191 end
184 if session.conn and session.conn.resume_writes then 192 if session.conn and session.conn.resume_writes then