Software /
code /
prosody
Comparison
plugins/mod_smacks.lua @ 12678:5a61e1603f42
mod_smacks: Don't close resuming session when failed due to overflow
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 26 Aug 2022 17:28:06 +0100 |
parent | 12677:3b9771d496ed |
child | 12682:464a22f2751c |
comparison
equal
deleted
inserted
replaced
12677:3b9771d496ed | 12678:5a61e1603f42 |
---|---|
568 age = now - original_session.hibernating; | 568 age = now - original_session.hibernating; |
569 end | 569 end |
570 | 570 |
571 session.log("debug", "mod_smacks resuming existing session %s...", original_session.id); | 571 session.log("debug", "mod_smacks resuming existing session %s...", original_session.id); |
572 | 572 |
573 local queue = original_session.outgoing_stanza_queue; | |
574 local h = tonumber(stanza.attr.h); | |
575 | |
576 original_session.log("debug", "Pre-resumption #queue = %d", queue:count_unacked()) | |
577 local acked, err = ack_errors.coerce(queue:ack(h)); -- luacheck: ignore 211/acked | |
578 | |
579 if not err and not queue:resumable() then | |
580 err = ack_errors.new("overflow"); | |
581 end | |
582 | |
583 if err then | |
584 session.send(st.stanza("failed", | |
585 { xmlns = xmlns_sm; h = format_h(original_session.handled_stanza_count); previd = id })); | |
586 session.log("debug", "Resumption failed: %s", err); | |
587 return true; | |
588 end | |
589 | |
573 -- Update original_session with the parameters (connection, etc.) from the new session | 590 -- Update original_session with the parameters (connection, etc.) from the new session |
574 sessionmanager.update_session(original_session, session); | 591 sessionmanager.update_session(original_session, session); |
575 | 592 |
576 local queue = original_session.outgoing_stanza_queue; | 593 -- Inform client of successful resumption |
577 local h = tonumber(stanza.attr.h); | |
578 | |
579 original_session.log("debug", "Pre-resumption #queue = %d", queue:count_unacked()) | |
580 local acked, err = ack_errors.coerce(queue:ack(h)); -- luacheck: ignore 211/acked | |
581 | |
582 if not err and not queue:resumable() then | |
583 err = ack_errors.new("overflow"); | |
584 end | |
585 | |
586 if err or not queue:resumable() then | |
587 original_session.send(st.stanza("failed", | |
588 { xmlns = xmlns_sm; h = format_h(original_session.handled_stanza_count); previd = id })); | |
589 original_session:close(err); | |
590 return false; | |
591 end | |
592 | |
593 original_session.send(st.stanza("resumed", { xmlns = xmlns_sm, | 594 original_session.send(st.stanza("resumed", { xmlns = xmlns_sm, |
594 h = format_h(original_session.handled_stanza_count), previd = id })); | 595 h = format_h(original_session.handled_stanza_count), previd = id })); |
595 | 596 |
596 -- Ok, we need to re-send any stanzas that the client didn't see | 597 -- Ok, we need to re-send any stanzas that the client didn't see |
597 -- ...they are what is now left in the outgoing stanza queue | 598 -- ...they are what is now left in the outgoing stanza queue |