# HG changeset patch # User Matthew Wild # Date 1754395888 -3600 # Node ID 52cf3ec248a90543d907e595431afd77b6eba2fc # Parent 33755e085ca5c8c60730bbe07ee54f34a419009d mod_c2s: Avoid calling module:context() with unknown hosts Related to e6c6f58dfda1, a0faff6ba853 and #605 diff -r 33755e085ca5 -r 52cf3ec248a9 plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Sun Aug 03 15:21:56 2025 +0200 +++ b/plugins/mod_c2s.lua Tue Aug 05 13:11:28 2025 +0100 @@ -210,7 +210,11 @@ local function session_close(session, reason) local log = session.log or log; local close_event_payload = { session = session, reason = reason }; - module:context(session.host):fire_event("pre-session-close", close_event_payload); + + -- Fire event on host if we know it, otherwise fire globally + local context = hosts[session.host] and module:context(session.host) or module:context("*"); + context:fire_event("pre-session-close", close_event_payload); + reason = close_event_payload.reason; if session.conn then if session.notopen then