Software / code / prosody
Comparison
plugins/mod_smacks.lua @ 13543:01d2abc3d17c 0.12
mod_smacks: Destroy timed out session in async context (fixes #1884)
Prevents ASYNC-01 due to storage interactions in a timer.
Also considered modifying mod_c2s to allow passing arbitrary closures
into its runner thread but this seems like a big step away from the
current code for just this module.
Also considered creating a dedicated runner in mod_smacks, but ensuring
continuity across module reloads might be tricky.
We could further improve this in the next major version.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 02 Nov 2024 18:10:25 +0100 |
| parent | 13022:a313b7260145 |
| child | 13544:0aae6de9d323 |
comparison
equal
deleted
inserted
replaced
| 13528:c228f1ffb7b3 | 13543:01d2abc3d17c |
|---|---|
| 492 -- This should normally not happen, the watchdog should be canceled from session:close() | 492 -- This should normally not happen, the watchdog should be canceled from session:close() |
| 493 session.log("debug", "The session has already been resumed or replaced"); | 493 session.log("debug", "The session has already been resumed or replaced"); |
| 494 return | 494 return |
| 495 end | 495 end |
| 496 | 496 |
| 497 session.log("debug", "Destroying session for hibernating too long"); | 497 prosody.main_thread:run(function () |
| 498 session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil; | 498 session.log("debug", "Destroying session for hibernating too long"); |
| 499 old_session_registry:set(session.username, session.resumption_token, | 499 session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil; |
| 500 { h = session.handled_stanza_count; t = os.time() }); | 500 old_session_registry:set(session.username, session.resumption_token, |
| 501 session.resumption_token = nil; | 501 { h = session.handled_stanza_count; t = os.time() }); |
| 502 session.resending_unacked = true; -- stop outgoing_stanza_filter from re-queueing anything anymore | 502 session.resumption_token = nil; |
| 503 sessionmanager.destroy_session(session, "Hibernating too long"); | 503 session.resending_unacked = true; -- stop outgoing_stanza_filter from re-queueing anything anymore |
| 504 sessions_expired(1); | 504 sessionmanager.destroy_session(session, "Hibernating too long"); |
| 505 sessions_expired(1); | |
| 506 end); | |
| 505 end); | 507 end); |
| 506 if session.conn then | 508 if session.conn then |
| 507 local conn = session.conn; | 509 local conn = session.conn; |
| 508 c2s_sessions[conn] = nil; | 510 c2s_sessions[conn] = nil; |
| 509 session.conn = nil; | 511 session.conn = nil; |