core/sessionmanager.lua
branchs2s
changeset 148 4c0dcd245d34
parent 145 fbb3a4ff9cf1
child 150 d09b8a1ab046
--- a/core/sessionmanager.lua	Fri Oct 24 06:13:38 2008 +0100
+++ b/core/sessionmanager.lua	Fri Oct 24 07:27:36 2008 +0100
@@ -35,14 +35,15 @@
 
 function destroy_session(session)
 	session.log("info", "Destroying session");
-	if session.username then
+	if session.host and session.username then
 		if session.resource then
 			hosts[session.host].sessions[session.username].sessions[session.resource] = nil;
 		end
-		
-		if not next(hosts[session.host].sessions[session.username].sessions) then
-			log("debug", "All resources of %s are now offline", session.username);
-			hosts[session.host].sessions[session.username] = nil;
+		if hosts[session.host] and hosts[session.host].sessions[session.username] then
+			if not next(hosts[session.host].sessions[session.username].sessions) then
+				log("debug", "All resources of %s are now offline", session.username);
+				hosts[session.host].sessions[session.username] = nil;
+			end
 		end
 	end
 	session.conn = nil;