mod_saslauth_muc: Improved timer handling.
authorWaqas Hussain <waqas20@gmail.com>
Tue, 14 Dec 2010 00:03:24 +0500
changeset 287 6144fe6161f1
parent 286 ca6199d73d68
child 288 9233d7ee3c09
mod_saslauth_muc: Improved timer handling.
mod_saslauth_muc/mod_saslauth_muc.lua
--- a/mod_saslauth_muc/mod_saslauth_muc.lua	Tue Dec 14 00:02:10 2010 +0500
+++ b/mod_saslauth_muc/mod_saslauth_muc.lua	Tue Dec 14 00:03:24 2010 +0500
@@ -42,8 +42,7 @@
 end
 
 -- Timer to clear SASL sessions
-timer.add_task(timeout, function()
-	local now = os_time();
+timer.add_task(timeout, function(now)
 	for room, handlers in pairs(_rooms) do
 		for jid, handler in pairs(handlers) do
 			if handler.timeout <= now then handlers[jid] = nil; end
@@ -52,6 +51,9 @@
 	end
 	return timeout;
 end);
+function module.unload()
+	timeout = nil; -- stop timer on unload
+end
 
 -- Stanza handlers
 module:hook("presence/full", function(event)