aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_smacks.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-17 16:21:26 +0100
committerKim Alvefur <zash@zash.se>2021-12-17 16:21:26 +0100
commit2e47306cb6f1391842ac7790178605b703ee110a (patch)
treec47f10e2d0a39a35ccda829c9ab9b00c2a1d61ee /plugins/mod_smacks.lua
parent685974b5d35f5429d4ea718fc94407b18044fb1f (diff)
downloadprosody-2e47306cb6f1391842ac7790178605b703ee110a.tar.gz
prosody-2e47306cb6f1391842ac7790178605b703ee110a.zip
mod_smacks: Bounce unacked stanzas on shutdown
Diffstat (limited to 'plugins/mod_smacks.lua')
-rw-r--r--plugins/mod_smacks.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua
index 8f8c827f..c776b35a 100644
--- a/plugins/mod_smacks.lua
+++ b/plugins/mod_smacks.lua
@@ -634,7 +634,8 @@ end
module:hook("s2s-read-timeout", handle_read_timeout);
module:hook("c2s-read-timeout", handle_read_timeout);
-module:hook_global("server-stopping", function()
+module:hook_global("server-stopping", function(event)
+ local reason = event.reason;
-- Close smacks-enaled sessions ourselves instead of letting mod_c2s close
-- it, which invalidates the smacks session. This allows preserving the
-- counter value, so it can be communicated to the client when it tries to
@@ -644,12 +645,21 @@ module:hook_global("server-stopping", function()
if session.resumption_token then
if old_session_registry:set(session.username, session.resumption_token, { h = session.handled_stanza_count }) then
session.resumption_token = nil;
+
+ -- Deal with unacked stanzas
+ if session.outgoing_stanza_queue then
+ handle_unacked_stanzas(session);
+ end
+
if session.conn then
session.conn:close()
session.conn = nil;
-- Now when mod_c2s gets here, it will immediately destroy the
-- session since it is unconnected.
end
+
+ -- And make sure nobody tries to send anything
+ session:close{ condition = "system-shutdown", text = reason };
end
end
end