mod_smacks: Run session destruction code in session's async context

This is the Right Thing and should fix various potential issues and race
conditions.
This commit is contained in:
Matthew Wild 2024-11-21 17:02:55 +00:00
parent 6bbfcd801a
commit 9de5f1149b

View file

@ -541,13 +541,17 @@ module:hook("pre-resource-unbind", function (event)
return
end
prosody.main_thread:run(function ()
session.log("debug", "Destroying session for hibernating too long");
save_old_session(session);
session.resumption_token = nil;
sessionmanager.destroy_session(session, "Hibernating too long");
sessions_expired(1);
end);
session.thread:run({
event = "callback";
name = "mod_smacks/destroy_hibernating";
callback = function ()
session.log("debug", "Destroying session for hibernating too long");
save_old_session(session);
session.resumption_token = nil;
sessionmanager.destroy_session(session, "Hibernating too long");
sessions_expired(1);
end;
});
end);
if session.conn then
local conn = session.conn;