diff plugins/mod_c2s.lua @ 14146:1d028f9473c2 13.0

mod_c2s, mod_smacks: Refactor session/connection cleanup mod_smacks was preventing mod_c2s cleanup by directly modifying the mod_c2s sessions table. It did this to avoid mod_c2s trying to destroy the session when the connection was closed. The code that does IP counting in mod_limits was experiencing counter drift, likely because of mod_smacks disassociating the session from the connection before the c2s-closed event is fired. This change has mod_c2s skip the session cleanup if it sees the 'hibernating' property is set on the session. This is a less invasive way of performing the same thing. Importantly, c2s-closed still gets to run and fire with the original session object. It might be desirable to remove the 'hibernating' check here and switch to a more generic event-driven design (where mod_smacks can inhibit cleanup by adding an event handler). This change was deemed too large for a minor release, but may be made in trunk.
author Matthew Wild <mwild1@gmail.com>
date Tue, 21 Apr 2026 16:22:43 +0100
parents 836a70deb3c9
children 320e1d49aa9e e3ddbf7f2d3f
line wrap: on
line diff
--- a/plugins/mod_c2s.lua	Fri Apr 17 19:42:44 2026 +0100
+++ b/plugins/mod_c2s.lua	Tue Apr 21 16:22:43 2026 +0100
@@ -438,7 +438,9 @@
 	if session then
 		(session.log or log)("info", "Client disconnected: %s", err or "connection closed");
 		stop_session_timers(session);
-		sm_destroy_session(session, err);
+		if not session.hibernating then
+			sm_destroy_session(session, err);
+		end
 		session.conn = nil;
 		sessions[conn]  = nil;
 	end