Changeset

981:71fce47dff7b

mod_component: Deregister component on disconnect
author Matthew Wild <mwild1@gmail.com>
date Sat, 11 Apr 2009 22:22:24 +0100
parents 980:b52d442161f2
children 982:dbbeb73952e6
files plugins/mod_component.lua
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_component.lua	Sat Apr 11 16:13:40 2009 +0100
+++ b/plugins/mod_component.lua	Sat Apr 11 22:22:24 2009 +0100
@@ -14,6 +14,7 @@
 
 local connlisteners = require "net.connlisteners";
 local cm_register_component = require "core.componentmanager".register_component;
+local cm_deregister_component = require "core.componentmanager".deregister_component;
 local uuid_gen = require "util.uuid".generate;
 local sha1 = require "util.hashes".sha1;
 local st = stanza;
@@ -196,9 +197,9 @@
 	if session then
 		(session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err));
 		if session.host then
-			if session.component then
-				deregister_component(session.host);
-			end
+			log("debug", "deregistering component");
+			cm_deregister_component(session.host);
+			hosts[session.host].connected = nil;
 		end
 		sessions[conn]  = nil;
 		session = nil;