Software /
code /
prosody
Comparison
plugins/mod_smacks.lua @ 11938:6da703cb4c04
mod_smacks: Optimize scheduling of ack requests
Taking advantage of the new callbacks added in dcf38ac6a38c and
9c450185bac1 avoids extra timers, extra syscalls and sending the `<r>`
in its own TCP segment, improving efficiency.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Nov 2021 21:27:49 +0100 |
parent | 11937:364c3f018e3a |
child | 11952:b78a341e72e7 |
comparison
equal
deleted
inserted
replaced
11937:364c3f018e3a | 11938:6da703cb4c04 |
---|---|
234 if session.hibernating then | 234 if session.hibernating then |
235 session.log("debug", "hibernating since %s, stanza queued", datetime.datetime(session.hibernating)); | 235 session.log("debug", "hibernating since %s, stanza queued", datetime.datetime(session.hibernating)); |
236 module:fire_event("smacks-hibernation-stanza-queued", {origin = session, queue = queue, stanza = cached_stanza}); | 236 module:fire_event("smacks-hibernation-stanza-queued", {origin = session, queue = queue, stanza = cached_stanza}); |
237 return nil; | 237 return nil; |
238 end | 238 end |
239 request_ack_if_needed(session, false, "outgoing_stanza_filter", stanza); | |
240 end | 239 end |
241 return stanza; | 240 return stanza; |
242 end | 241 end |
243 | 242 |
244 local function count_incoming_stanzas(stanza, session) | 243 local function count_incoming_stanzas(stanza, session) |
650 -- Events when it's sensible to request an ack | 649 -- Events when it's sensible to request an ack |
651 -- Could experiment with forcing (ignoring max_unacked) <r>, but when and why? | 650 -- Could experiment with forcing (ignoring max_unacked) <r>, but when and why? |
652 local request_ack_events = { | 651 local request_ack_events = { |
653 ["csi-client-active"] = true; | 652 ["csi-client-active"] = true; |
654 ["csi-flushing"] = false; | 653 ["csi-flushing"] = false; |
654 ["c2s-pre-ondrain"] = false; | |
655 ["s2s-pre-ondrain"] = false; | |
655 }; | 656 }; |
656 | 657 |
657 for event_name, force in pairs(request_ack_events) do | 658 for event_name, force in pairs(request_ack_events) do |
658 module:log("info", "module:hook(%q, function)"); | 659 module:log("info", "module:hook(%q, function)"); |
659 module:hook(event_name, function(event) | 660 module:hook(event_name, function(event) |