Software /
code /
prosody
Comparison
plugins/mod_csi_simple.lua @ 10277:45a58127a3e5
mod_csi_simple: Remove duplicated check for connection
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 28 Sep 2019 22:59:29 +0200 |
parent | 10025:4498f601516d |
child | 10302:4c53e58d2468 |
comparison
equal
deleted
inserted
replaced
10276:4e4ce7400b39 | 10277:45a58127a3e5 |
---|---|
79 session.conn:resume_writes(); | 79 session.conn:resume_writes(); |
80 return data; | 80 return data; |
81 end | 81 end |
82 | 82 |
83 function enable_optimizations(session) | 83 function enable_optimizations(session) |
84 if session.conn and session.conn and session.conn.pause_writes then | 84 if session.conn and session.conn.pause_writes then |
85 session.conn:pause_writes(); | 85 session.conn:pause_writes(); |
86 filters.add_filter(session, "stanzas/out", manage_buffer); | 86 filters.add_filter(session, "stanzas/out", manage_buffer); |
87 filters.add_filter(session, "bytes/in", flush_buffer); | 87 filters.add_filter(session, "bytes/in", flush_buffer); |
88 else | 88 else |
89 session.log("warn", "Session connection does not support write pausing"); | 89 session.log("warn", "Session connection does not support write pausing"); |
90 end | 90 end |
91 end | 91 end |
92 | 92 |
93 function disable_optimizations(session) | 93 function disable_optimizations(session) |
94 if session.conn and session.conn and session.conn.resume_writes then | 94 if session.conn and session.conn.resume_writes then |
95 filters.remove_filter(session, "stanzas/out", manage_buffer); | 95 filters.remove_filter(session, "stanzas/out", manage_buffer); |
96 filters.remove_filter(session, "bytes/in", flush_buffer); | 96 filters.remove_filter(session, "bytes/in", flush_buffer); |
97 session.conn:resume_writes(); | 97 session.conn:resume_writes(); |
98 end | 98 end |
99 end | 99 end |
113 disable_optimizations(session); | 113 disable_optimizations(session); |
114 end); | 114 end); |
115 | 115 |
116 module:hook("c2s-ondrain", function (event) | 116 module:hook("c2s-ondrain", function (event) |
117 local session = event.session; | 117 local session = event.session; |
118 if session.state == "inactive" and session.conn and session.conn and session.conn.pause_writes then | 118 if session.state == "inactive" and session.conn and session.conn.pause_writes then |
119 session.conn:pause_writes(); | 119 session.conn:pause_writes(); |
120 session.log("debug", "Buffer flushed, resuming inactive mode (queue size was %d)", session.csi_counter); | 120 session.log("debug", "Buffer flushed, resuming inactive mode (queue size was %d)", session.csi_counter); |
121 session.csi_counter = 0; | 121 session.csi_counter = 0; |
122 end | 122 end |
123 end); | 123 end); |