Software /
code /
prosody
Comparison
plugins/mod_smacks.lua @ 12061:31a7e0ac6928
mod_smacks: Skip hibernation logic if session was closed or replaced
The resumption_token is removed when the session is closed via the
pre-session-close event, signaling that it cannot be resumed, and
therefore no hibernation timeout logic should be invoked.
Fixes that if a session somehow is replaced by a new one using the same
resource (which is the common behavior), the old session would still be
around until it times out at which point it sends `<presence
type="unavailable"/>` which would look as if it came from the new
session, ie appearing offline to everyone including MUCs.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 16 Dec 2021 22:59:51 +0100 |
parent | 12060:3099e03b10bd |
child | 12062:4972244fe87b |
comparison
equal
deleted
inserted
replaced
12060:3099e03b10bd | 12061:31a7e0ac6928 |
---|---|
433 session.hibernating = os_time(); | 433 session.hibernating = os_time(); |
434 session.hibernating_watchdog = watchdog.new(resume_timeout, function() | 434 session.hibernating_watchdog = watchdog.new(resume_timeout, function() |
435 session.log("debug", "mod_smacks hibernation timeout reached..."); | 435 session.log("debug", "mod_smacks hibernation timeout reached..."); |
436 if session.destroyed then | 436 if session.destroyed then |
437 session.log("debug", "The session has already been destroyed"); | 437 session.log("debug", "The session has already been destroyed"); |
438 return | |
439 elseif not session.resumption_token then | |
440 -- This should normally not happen, the watchdog should be canceled from session:close() | |
441 session.log("debug", "The session has already been resumed or replaced"); | |
438 return | 442 return |
439 end | 443 end |
440 | 444 |
441 session.log("debug", "Destroying session for hibernating too long"); | 445 session.log("debug", "Destroying session for hibernating too long"); |
442 session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil; | 446 session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil; |