Changeset

3103:5bf79bb3cf7e

Neuter 0198 from mod_pinger, fix #712
author Georg Lukas <georg@op-co.de>
date Wed, 06 Jun 2018 19:20:10 +0200
parents 3102:f04dbfad5407
children 3104:626d2c781c66
files mod_pinger/mod_pinger.lua
diffstat 1 files changed, 7 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pinger/mod_pinger.lua	Sun Jun 03 16:26:32 2018 +0200
+++ b/mod_pinger/mod_pinger.lua	Wed Jun 06 19:20:10 2018 +0200
@@ -13,16 +13,14 @@
 
 function check_session(watchdog)
 	local session = watchdog.session;
+	if session.smacks then
+		unwatch_session(session);
+		return;
+	end
 	if not session.idle_pinged then
 		session.idle_pinged = true;
-		if session.smacks then
-			if not session.awaiting_ack then
-				session.send(st.stanza("r", { xmlns = session.smacks }))
-			end
-		else
-			session.send(st.iq({ type = "get", from = module.host, id = "idle-check" })
-					:tag("ping", { xmlns = "urn:xmpp:ping" }));
-		end
+		session.send(st.iq({ type = "get", from = module.host, id = "idle-check" })
+				:tag("ping", { xmlns = "urn:xmpp:ping" }));
 		return ping_timeout; -- Call us again after ping_timeout
 	else
 		module:log("info", "Client %q silent for too long, closing...", session.full_jid);
@@ -42,15 +40,11 @@
 
 function unwatch_session(session)
 	if session.idle_watchdog then
+		filters.remove_filter(session, "bytes/in", update_watchdog);
 		session.idle_watchdog:cancel();
 		session.idle_watchdog = nil;
-		filters.remove_filter(session, "bytes/in", update_watchdog);
 	end
 end
 
 module:hook("resource-bind", function (event) watch_session(event.session); end);
 module:hook("resource-unbind", function (event) unwatch_session(event.session); end);
-
--- handle smacks sessions properly (not pinging in hibernated state)
-module:hook("smacks-hibernation-start", function (event) unwatch_session(event.origin); end);
-module:hook("smacks-hibernation-end", function (event) watch_session(event.resumed); end);