Mercurial > prosody-modules
comparison mod_cloud_notify/mod_cloud_notify.lua @ 4412:e5493a10c4d1
mod_cloud_notify: use stanza from mod_smacks to behave O(1)
This uses the provided stanza in the ack-delayed smacks event to trigger push
for this stanza only rather than iterating through the whole smacks queue
to find the first unpushed stanza.
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sat, 30 Jan 2021 07:17:33 +0100 |
parents | 33f82988d7a9 |
children | 157fa4e535b0 |
comparison
equal
deleted
inserted
replaced
4411:c3d21182ebf3 | 4412:e5493a10c4d1 |
---|---|
474 | 474 |
475 -- smacks hibernation is ended | 475 -- smacks hibernation is ended |
476 local function restore_session(event) | 476 local function restore_session(event) |
477 local session = event.resumed; | 477 local session = event.resumed; |
478 if session then -- older smacks module versions send only the "intermediate" session in event.session and no session.resumed one | 478 if session then -- older smacks module versions send only the "intermediate" session in event.session and no session.resumed one |
479 if session.awaiting_push_timer then session.awaiting_push_timer:stop(); end | 479 if session.awaiting_push_timer then |
480 session.awaiting_push_timer:stop(); | |
481 session.awaiting_push_timer = nil; | |
482 end | |
480 session.first_hibernated_push = nil; | 483 session.first_hibernated_push = nil; |
481 end | 484 end |
482 end | 485 end |
483 | 486 |
484 -- smacks ack is delayed | 487 -- smacks ack is delayed |
485 local function ack_delayed(event) | 488 local function ack_delayed(event) |
486 local session = event.origin; | 489 local session = event.origin; |
487 local queue = event.queue; | 490 local queue = event.queue; |
491 local stanza = event.stanza; | |
488 if not session.push_identifier then return; end | 492 if not session.push_identifier then return; end |
493 if stanza then process_stanza(session, stanza); return; end -- don't iterate through smacks queue if we know which stanza triggered this | |
489 for i=1, #queue do | 494 for i=1, #queue do |
490 local stanza = queue[i]; | 495 local stanza = queue[i]; |
491 -- process unacked stanzas (handle_notify_request() will only send push requests for new stanzas) | 496 -- process unacked stanzas (handle_notify_request() will only send push requests for new stanzas) |
492 process_stanza(session, stanza); | 497 process_stanza(session, stanza); |
493 end | 498 end |