Mercurial > prosody-modules
comparison mod_smacks/mod_smacks.lua @ 3841:b5d367798570
Fix bug readding stanzas to outgoing_queue on resume
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Thu, 09 Jan 2020 21:21:09 +0100 |
parents | 58047d6f2b89 |
children | c49fea05772e |
comparison
equal
deleted
inserted
replaced
3840:054898e84a04 | 3841:b5d367798570 |
---|---|
3 -- Copyright (C) 2010-2015 Matthew Wild | 3 -- Copyright (C) 2010-2015 Matthew Wild |
4 -- Copyright (C) 2010 Waqas Hussain | 4 -- Copyright (C) 2010 Waqas Hussain |
5 -- Copyright (C) 2012-2015 Kim Alvefur | 5 -- Copyright (C) 2012-2015 Kim Alvefur |
6 -- Copyright (C) 2012 Thijs Alkemade | 6 -- Copyright (C) 2012 Thijs Alkemade |
7 -- Copyright (C) 2014 Florian Zeitz | 7 -- Copyright (C) 2014 Florian Zeitz |
8 -- Copyright (C) 2016-2019 Thilo Molitor | 8 -- Copyright (C) 2016-2020 Thilo Molitor |
9 -- | 9 -- |
10 -- This project is MIT/X11 licensed. Please see the | 10 -- This project is MIT/X11 licensed. Please see the |
11 -- COPYING file in the source package for more information. | 11 -- COPYING file in the source package for more information. |
12 -- | 12 -- |
13 | 13 |
556 original_session:dispatch_stanza(st.stanza("a", { xmlns = xmlns_sm, | 556 original_session:dispatch_stanza(st.stanza("a", { xmlns = xmlns_sm, |
557 h = stanza.attr.h })); | 557 h = stanza.attr.h })); |
558 | 558 |
559 -- Ok, we need to re-send any stanzas that the client didn't see | 559 -- Ok, we need to re-send any stanzas that the client didn't see |
560 -- ...they are what is now left in the outgoing stanza queue | 560 -- ...they are what is now left in the outgoing stanza queue |
561 -- We have to use the send of "session" because we don't want to add our resent stanzas | |
562 -- to the outgoing queue again | |
561 local queue = original_session.outgoing_stanza_queue; | 563 local queue = original_session.outgoing_stanza_queue; |
562 original_session.log("debug", "#queue = %d", #queue); | 564 session.log("debug", "resending all unacked stanzas that are still queued after resume, #queue = %d", #queue); |
563 for i=1,#queue do | 565 for i=1,#queue do |
564 original_session.send(queue[i]); | 566 session.send(queue[i]); |
565 end | 567 end |
566 original_session.log("debug", "#queue = %d -- after send", #queue); | 568 session.log("debug", "all stanzas resent, now disabling send() in this session, #queue = %d", #queue); |
567 function session.send(stanza) | 569 function session.send(stanza) |
568 session.log("warn", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza)); | 570 session.log("warn", "Tried to send stanza on old session migrated by smacks resume (maybe there is a bug?): %s", tostring(stanza)); |
569 return false; | 571 return false; |
570 end | 572 end |
571 module:fire_event("smacks-hibernation-end", {origin = session, resumed = original_session, queue = queue}); | 573 module:fire_event("smacks-hibernation-end", {origin = session, resumed = original_session, queue = queue}); |