Mercurial > prosody-modules
comparison mod_smacks/mod_smacks.lua @ 908:abf0f12fe75c
mod_smacks: Don't try to send stanzas to hibernating sessions. Fixes duplicate IQ replies on libevent.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 11 Feb 2013 19:21:31 +0100 |
parents | e089160c424b |
children | 720b8268778e |
comparison
equal
deleted
inserted
replaced
907:c06369259aee | 908:abf0f12fe75c |
---|---|
80 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then | 80 if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then |
81 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); | 81 cached_stanza = cached_stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()}); |
82 end | 82 end |
83 | 83 |
84 queue[#queue+1] = cached_stanza; | 84 queue[#queue+1] = cached_stanza; |
85 end | |
86 if session.hibernating then | |
87 -- The session is hibernating, no point in sending the stanza | |
88 -- over a dead connection. It will be delivered upon resumption. | |
89 return true; | |
85 end | 90 end |
86 local ok, err = _send(stanza); | 91 local ok, err = _send(stanza); |
87 if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and attr and not attr.xmlns then | 92 if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and attr and not attr.xmlns then |
88 session.awaiting_ack = true; | 93 session.awaiting_ack = true; |
89 return _send(st.stanza("r", sm_attr)); | 94 return _send(st.stanza("r", sm_attr)); |