Mercurial > prosody-modules
comparison mod_cloud_notify/mod_cloud_notify.lua @ 3979:6bf362008052
mod_cloud_notify: make stanza queue processing faster
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sun, 19 Apr 2020 08:12:21 +0200 |
parents | f5e6368a1c39 |
children | 42682505e692 |
comparison
equal
deleted
inserted
replaced
3978:dd8ef22d4857 | 3979:6bf362008052 |
---|---|
373 if not session.push_identifier then return; end | 373 if not session.push_identifier then return; end |
374 local user_push_services = {[session.push_identifier] = session.push_settings}; | 374 local user_push_services = {[session.push_identifier] = session.push_settings}; |
375 local notified = { unimportant = false; important = false } | 375 local notified = { unimportant = false; important = false } |
376 for i=1, #queue do | 376 for i=1, #queue do |
377 local stanza = queue[i]; | 377 local stanza = queue[i]; |
378 local node = get_push_settings(stanza, session); | 378 -- fast ignore of already pushed stanzas |
379 stanza_type = "unimportant" | 379 if stanza and not (stanza._push_notify and stanza._push_notify[session.push_identifier]) then |
380 if dummy_body and is_important(stanza) then stanza_type = "important"; end | 380 local node = get_push_settings(stanza, session); |
381 if not notified[stanza_type] then -- only notify if we didn't try to push for this stanza type already | 381 stanza_type = "unimportant" |
382 -- session.log("debug", "Invoking cloud handle_notify_request() for smacks queued stanza: %d", i); | 382 if dummy_body and is_important(stanza) then stanza_type = "important"; end |
383 if handle_notify_request(stanza, node, user_push_services, false) ~= 0 then | 383 if not notified[stanza_type] then -- only notify if we didn't try to push for this stanza type already |
384 if session.hibernating and not session.first_hibernated_push then | 384 -- session.log("debug", "Invoking cloud handle_notify_request() for smacks queued stanza: %d", i); |
385 -- if important stanzas are treated differently (pushed with last-message-body field set to dummy string) | 385 if handle_notify_request(stanza, node, user_push_services, false) ~= 0 then |
386 -- and the message was important (e.g. had a last-message-body field) OR if we treat all pushes equally, | 386 if session.hibernating and not session.first_hibernated_push then |
387 -- then record the time of first push in the session for the smack module which will extend its hibernation | 387 -- if important stanzas are treated differently (pushed with last-message-body field set to dummy string) |
388 -- timeout based on the value of session.first_hibernated_push | 388 -- if the message was important (e.g. had a last-message-body field) OR if we treat all pushes equally, |
389 if not dummy_body or (dummy_body and is_important(stanza)) then | 389 -- then record the time of first push in the session for the smack module which will extend its hibernation |
390 session.first_hibernated_push = os_time(); | 390 -- timeout based on the value of session.first_hibernated_push |
391 if not dummy_body or (dummy_body and is_important(stanza)) then | |
392 session.first_hibernated_push = os_time(); | |
393 end | |
391 end | 394 end |
395 session.log("debug", "Cloud handle_notify_request() > 0, not notifying for other %s queued stanzas of type %s", queue_type, stanza_type); | |
396 notified[stanza_type] = true | |
392 end | 397 end |
393 session.log("debug", "Cloud handle_notify_request() > 0, not notifying for other %s queued stanzas of type %s", queue_type, stanza_type); | 398 end |
394 notified[stanza_type] = true | 399 end |
395 end | 400 if notified.unimportant and notified.important then break; end -- stop processing the queue if all push types are exhausted |
396 end | |
397 end | 401 end |
398 end | 402 end |
399 | 403 |
400 -- publish on unacked smacks message (use timer to send out push for all stanzas submitted in a row only once) | 404 -- publish on unacked smacks message (use timer to send out push for all stanzas submitted in a row only once) |
401 local function process_smacks_stanza(stanza, session) | 405 local function process_smacks_stanza(stanza, session) |