Mercurial > prosody-modules
comparison mod_smacks/mod_smacks.lua @ 2148:c472a454be61
mod_smacks: Fix sending <r> after stanzas while not creating multiple timers (thanks Thilo)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 02 Apr 2016 20:03:30 +0200 |
| parents | 3a94b3cd31e2 |
| children | 48c3d64a3fc1 |
comparison
equal
deleted
inserted
replaced
| 2147:ed2bb50d4f91 | 2148:c472a454be61 |
|---|---|
| 85 session.log("debug", "#queue = %d", #queue); | 85 session.log("debug", "#queue = %d", #queue); |
| 86 if session.hibernating then | 86 if session.hibernating then |
| 87 session.log("debug", "hibernating, stanza queued"); | 87 session.log("debug", "hibernating, stanza queued"); |
| 88 return nil; | 88 return nil; |
| 89 end | 89 end |
| 90 if #queue > max_unacked_stanzas and not session.awaiting_ack then | 90 if #queue > max_unacked_stanzas and session.awaiting_ack == nil then |
| 91 session.log("debug", "Queuing <r> (in a moment)"); | 91 session.log("debug", "Queuing <r> (in a moment)"); |
| 92 session.awaiting_ack = true; | 92 session.awaiting_ack = false; |
| 93 session.awaiting_ack_timer = module:add_timer(1e-06, function () | 93 session.awaiting_ack_timer = module:add_timer(1e-06, function () |
| 94 if not session.awaiting_ack then | 94 if not session.awaiting_ack then |
| 95 session.log("debug", "Sending <r> (after send)"); | 95 session.log("debug", "Sending <r> (after send)"); |
| 96 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })) | 96 (session.sends2s or session.send)(st.stanza("r", { xmlns = session.smacks })) |
| 97 session.awaiting_ack = true; | |
| 97 end | 98 end |
| 98 end); | 99 end); |
| 99 end | 100 end |
| 100 end | 101 end |
| 101 return stanza; | 102 return stanza; |
