Software /
code /
prosody
Annotate
plugins/mod_csi_simple.lua @ 9922:06bf5ccd859f
mod_csi_simple: Fix type in function name
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 25 Mar 2019 10:32:39 +0000 |
parent | 9921:ec138e4254ed |
child | 9923:e83dfcdeab59 |
rev | line source |
---|---|
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Copyright (C) 2016-2018 Kim Alvefur |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 -- |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- This project is MIT/X11 licensed. Please see the |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 -- COPYING file in the source package for more information. |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 -- |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 module:depends"csi" |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 local jid = require "util.jid"; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local st = require "util.stanza"; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local dt = require "util.datetime"; |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
12 local filters = require "util.filters"; |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 local queue_size = module:get_option_number("csi_queue_size", 256); |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 module:hook("csi-is-stanza-important", function (event) |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 local stanza = event.stanza; |
9632
fdefc43bffff
mod_csi_simple: Consider non-stanza objects important
Kim Alvefur <zash@zash.se>
parents:
9631
diff
changeset
|
18 if not st.is_stanza(stanza) then |
fdefc43bffff
mod_csi_simple: Consider non-stanza objects important
Kim Alvefur <zash@zash.se>
parents:
9631
diff
changeset
|
19 return true; |
fdefc43bffff
mod_csi_simple: Consider non-stanza objects important
Kim Alvefur <zash@zash.se>
parents:
9631
diff
changeset
|
20 end |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 local st_name = stanza.name; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 if not st_name then return false; end |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 local st_type = stanza.attr.type; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 if st_name == "presence" then |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 if st_type == nil or st_type == "unavailable" then |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 return false; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 return true; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 elseif st_name == "message" then |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 if st_type == "headline" then |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 return false; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 end |
9768
ab12fd48e124
mod_csi_simple: Consider messages forwarded from another of the users clients as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9767
diff
changeset
|
33 if stanza:get_child("sent", "urn:xmpp:carbons:2") then |
ab12fd48e124
mod_csi_simple: Consider messages forwarded from another of the users clients as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9767
diff
changeset
|
34 return true; |
ab12fd48e124
mod_csi_simple: Consider messages forwarded from another of the users clients as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9767
diff
changeset
|
35 end |
9769
150e9574c149
mod_csi_simple: Unpack Carbons-forwarded messages (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9768
diff
changeset
|
36 local forwarded = stanza:find("{urn:xmpp:carbons:2}received/{urn:xmpp:forward:0}/{jabber:client}message"); |
150e9574c149
mod_csi_simple: Unpack Carbons-forwarded messages (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9768
diff
changeset
|
37 if forwarded then |
150e9574c149
mod_csi_simple: Unpack Carbons-forwarded messages (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9768
diff
changeset
|
38 stanza = forwarded; |
150e9574c149
mod_csi_simple: Unpack Carbons-forwarded messages (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9768
diff
changeset
|
39 end |
9767
57ceffb13963
mod_csi_simple: Tweak check for <body>
Kim Alvefur <zash@zash.se>
parents:
9651
diff
changeset
|
40 if stanza:get_child("body") then |
57ceffb13963
mod_csi_simple: Tweak check for <body>
Kim Alvefur <zash@zash.se>
parents:
9651
diff
changeset
|
41 return true; |
57ceffb13963
mod_csi_simple: Tweak check for <body>
Kim Alvefur <zash@zash.se>
parents:
9651
diff
changeset
|
42 end |
9770
76cb409db537
mod_csi_simple: Consider messages with subject (eg MUC joins) (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9769
diff
changeset
|
43 if stanza:get_child("subject") then |
76cb409db537
mod_csi_simple: Consider messages with subject (eg MUC joins) (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9769
diff
changeset
|
44 return true; |
76cb409db537
mod_csi_simple: Consider messages with subject (eg MUC joins) (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9769
diff
changeset
|
45 end |
9771
bf92f37de137
mod_csi_simple: Consider messages encrypted payload as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9770
diff
changeset
|
46 if stanza:get_child("encryption", "urn:xmpp:eme:0") then |
bf92f37de137
mod_csi_simple: Consider messages encrypted payload as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9770
diff
changeset
|
47 return true; |
bf92f37de137
mod_csi_simple: Consider messages encrypted payload as important (fixes part of #1250)
Kim Alvefur <zash@zash.se>
parents:
9770
diff
changeset
|
48 end |
9767
57ceffb13963
mod_csi_simple: Tweak check for <body>
Kim Alvefur <zash@zash.se>
parents:
9651
diff
changeset
|
49 return false; |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 end |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 return true; |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 end, -1); |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 |
9911
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
54 local function with_timestamp(stanza, from) |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
55 if st.is_stanza(stanza) and stanza.attr.xmlns == nil and stanza.name ~= "iq" then |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
56 stanza = st.clone(stanza); |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
57 stanza:add_direct_child(st.stanza("delay", {xmlns = "urn:xmpp:delay", from = from, stamp = dt.datetime()})); |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
58 end |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
59 return stanza; |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
60 end |
ed011935c22d
mod_csi_simple: Break out stanza timestamping into a function for future reuse
Kim Alvefur <zash@zash.se>
parents:
9909
diff
changeset
|
61 |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
62 local function manage_buffer(stanza, session) |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
63 local ctr = session.csi_counter or 0; |
9921
ec138e4254ed
mod_csi_simple: Improve debug logs by mentioing why the buffer gets flushed
Kim Alvefur <zash@zash.se>
parents:
9920
diff
changeset
|
64 if ctr >= queue_size then |
ec138e4254ed
mod_csi_simple: Improve debug logs by mentioing why the buffer gets flushed
Kim Alvefur <zash@zash.se>
parents:
9920
diff
changeset
|
65 session.log("debug", "Queue size limit hit, flushing buffer"); |
ec138e4254ed
mod_csi_simple: Improve debug logs by mentioing why the buffer gets flushed
Kim Alvefur <zash@zash.se>
parents:
9920
diff
changeset
|
66 session.conn:resume_writes(); |
ec138e4254ed
mod_csi_simple: Improve debug logs by mentioing why the buffer gets flushed
Kim Alvefur <zash@zash.se>
parents:
9920
diff
changeset
|
67 elseif module:fire_event("csi-is-stanza-important", { stanza = stanza, session = session }) then |
ec138e4254ed
mod_csi_simple: Improve debug logs by mentioing why the buffer gets flushed
Kim Alvefur <zash@zash.se>
parents:
9920
diff
changeset
|
68 session.log("debug", "Important stanza, flushing buffer"); |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
69 session.conn:resume_writes(); |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
70 else |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
71 stanza = with_timestamp(stanza, jid.join(session.username, session.host)) |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
72 end |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
73 session.csi_counter = ctr + 1; |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
74 return stanza; |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
75 end |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
76 |
9913
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
77 local function flush_buffer(data, session) |
9920
4a56d7891bd3
mod_csi_simple: Add some debug logging
Kim Alvefur <zash@zash.se>
parents:
9919
diff
changeset
|
78 session.log("debug", "Client sent something, flushing buffer once"); |
9913
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
79 session.conn:resume_writes(); |
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
80 return data; |
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
81 end |
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
82 |
9918
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
83 function enable_optimizations(session) |
9909
3229be01a08a
mod_csi_simple: Use write locks in net.server if available
Kim Alvefur <zash@zash.se>
parents:
9771
diff
changeset
|
84 if session.conn and session.conn and session.conn.pause_writes then |
3229be01a08a
mod_csi_simple: Use write locks in net.server if available
Kim Alvefur <zash@zash.se>
parents:
9771
diff
changeset
|
85 session.conn:pause_writes(); |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
86 filters.add_filter(session, "stanzas/out", manage_buffer); |
9913
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
87 filters.add_filter(session, "bytes/in", flush_buffer); |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
88 else |
9917
45b5528b128a
mod_csi_simple: Remove old "pump" queue/buffer method, handled in net.server now
Kim Alvefur <zash@zash.se>
parents:
9914
diff
changeset
|
89 session.log("warn", "Session connection does not support write pausing"); |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
90 end |
9918
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
91 end |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
92 |
9922
06bf5ccd859f
mod_csi_simple: Fix type in function name
Matthew Wild <mwild1@gmail.com>
parents:
9921
diff
changeset
|
93 function disable_optimizations(session) |
9917
45b5528b128a
mod_csi_simple: Remove old "pump" queue/buffer method, handled in net.server now
Kim Alvefur <zash@zash.se>
parents:
9914
diff
changeset
|
94 if session.conn and session.conn and session.conn.resume_writes then |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
95 filters.remove_filter(session, "stanzas/out", manage_buffer); |
9913
7d78b24d8449
mod_csi_simple: Trigger buffer flush on seeing incoming data
Kim Alvefur <zash@zash.se>
parents:
9912
diff
changeset
|
96 filters.remove_filter(session, "bytes/in", flush_buffer); |
9909
3229be01a08a
mod_csi_simple: Use write locks in net.server if available
Kim Alvefur <zash@zash.se>
parents:
9771
diff
changeset
|
97 session.conn:resume_writes(); |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
98 end |
9918
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
99 end |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
100 |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
101 module:hook("csi-client-inactive", function (event) |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
102 local session = event.origin; |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
103 enable_optimizations(session); |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
104 end); |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
105 |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
106 module:hook("csi-client-active", function (event) |
6e9dcec259d0
mod_csi_simple: Separate out functions to enable/disable optimizations
Kim Alvefur <zash@zash.se>
parents:
9917
diff
changeset
|
107 local session = event.origin; |
9922
06bf5ccd859f
mod_csi_simple: Fix type in function name
Matthew Wild <mwild1@gmail.com>
parents:
9921
diff
changeset
|
108 disable_optimizations(session); |
9589
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
109 end); |
aeb054ee88c5
mod_csi_simple: Import modified version of mod_csi_pump from prosody-modules
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
110 |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
111 |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
112 module:hook("c2s-ondrain", function (event) |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
113 local session = event.session; |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
114 if session.state == "inactive" and session.conn and session.conn and session.conn.pause_writes then |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
115 session.csi_counter = 0; |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
116 session.conn:pause_writes(); |
9920
4a56d7891bd3
mod_csi_simple: Add some debug logging
Kim Alvefur <zash@zash.se>
parents:
9919
diff
changeset
|
117 session.log("debug", "Buffer flushed, resuming inactive mode"); |
9912
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
118 end |
601f9781a605
mod_csi_simple: Count buffered items and flush when it reaches configured limit
Kim Alvefur <zash@zash.se>
parents:
9911
diff
changeset
|
119 end); |
9919
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
120 |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
121 function module.load() |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
122 for _, user_session in pairs(prosody.hosts[module.host].sessions) do |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
123 for _, session in pairs(user_session.sessions) do |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
124 if session.state == "inactive" then |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
125 enable_optimizations(session); |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
126 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
127 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
128 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
129 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
130 |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
131 function module.unload() |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
132 for _, user_session in pairs(prosody.hosts[module.host].sessions) do |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
133 for _, session in pairs(user_session.sessions) do |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
134 if session.state == "inactive" then |
9922
06bf5ccd859f
mod_csi_simple: Fix type in function name
Matthew Wild <mwild1@gmail.com>
parents:
9921
diff
changeset
|
135 disable_optimizations(session); |
9919
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
136 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
137 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
138 end |
d602a495409b
mod_csi_simple: Disable optimizations on unload and re-enable on load
Kim Alvefur <zash@zash.se>
parents:
9918
diff
changeset
|
139 end |