Software /
code /
prosody
Comparison
plugins/mod_csi_simple.lua @ 9914:2c6b7247c3d9
mod_csi_simple: Also flush buffer in "pump" mode
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Mar 2019 19:02:40 +0100 |
parent | 9913:7d78b24d8449 |
child | 9917:45b5528b128a |
comparison
equal
deleted
inserted
replaced
9913:7d78b24d8449 | 9914:2c6b7247c3d9 |
---|---|
107 local function flush_buffer(data, session) | 107 local function flush_buffer(data, session) |
108 session.conn:resume_writes(); | 108 session.conn:resume_writes(); |
109 return data; | 109 return data; |
110 end | 110 end |
111 | 111 |
112 local function flush_pump(data, session) | |
113 session.pump:flush(); | |
114 return data; | |
115 end | |
116 | |
112 module:hook("csi-client-inactive", function (event) | 117 module:hook("csi-client-inactive", function (event) |
113 local session = event.origin; | 118 local session = event.origin; |
114 if session.conn and session.conn and session.conn.pause_writes then | 119 if session.conn and session.conn and session.conn.pause_writes then |
120 session.log("info", "Native net.server buffer management mode"); | |
115 session.conn:pause_writes(); | 121 session.conn:pause_writes(); |
116 filters.add_filter(session, "stanzas/out", manage_buffer); | 122 filters.add_filter(session, "stanzas/out", manage_buffer); |
117 filters.add_filter(session, "bytes/in", flush_buffer); | 123 filters.add_filter(session, "bytes/in", flush_buffer); |
118 elseif session.pump then | 124 elseif session.pump then |
119 session.pump:pause(); | 125 session.pump:pause(); |
122 local send = session.send; | 128 local send = session.send; |
123 session._orig_send = send; | 129 session._orig_send = send; |
124 local pump = new_pump(session.send, queue_size); | 130 local pump = new_pump(session.send, queue_size); |
125 pump:pause(); | 131 pump:pause(); |
126 session.pump = pump; | 132 session.pump = pump; |
133 filters.add_filter(session, "bytes/in", flush_pump); | |
127 function session.send(stanza) | 134 function session.send(stanza) |
128 if session.state == "active" or module:fire_event("csi-is-stanza-important", { stanza = stanza, session = session }) then | 135 if session.state == "active" or module:fire_event("csi-is-stanza-important", { stanza = stanza, session = session }) then |
129 pump:flush(); | 136 pump:flush(); |
130 send(stanza); | 137 send(stanza); |
131 else | 138 else |