Mercurial > prosody-modules
comparison mod_smacks/mod_smacks.lua @ 4771:e227af629736
mod_smacks: Send <r> immediately from csi-flushing event
Using a timer serves no purpose in this case, only serves to increase
the number of write syscalls and TCP segments sent.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 16 Nov 2021 13:39:49 +0100 |
| parents | 367a8020bd92 |
| children |
comparison
equal
deleted
inserted
replaced
| 4770:6ca2769da62a | 4771:e227af629736 |
|---|---|
| 648 if event.origin.smacks then | 648 if event.origin.smacks then |
| 649 request_ack_if_needed(event.origin, true, "csi-active", nil); | 649 request_ack_if_needed(event.origin, true, "csi-active", nil); |
| 650 end | 650 end |
| 651 end); | 651 end); |
| 652 | 652 |
| 653 module:hook("csi-flushing", function (event) | 653 module:hook("csi-flushing", function(event) |
| 654 if event.session.smacks then | 654 local session = event.session; |
| 655 request_ack_if_needed(event.session, true, "csi-active", nil); | 655 if session.smacks then |
| 656 if not session.awaiting_ack and not session.hibernating and not session.destroyed then | |
| 657 session.log("debug", "Sending <r> (csi-flushing)"); | |
| 658 session.awaiting_ack = true; -- The send() call may invoke this event again, so set this first | |
| 659 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })) | |
| 660 end | |
| 656 end | 661 end |
| 657 end); | 662 end); |
| 658 | 663 |
| 659 local function handle_read_timeout(event) | 664 local function handle_read_timeout(event) |
| 660 local session = event.session; | 665 local session = event.session; |
