From ed300f21f0256e4990a91fec79927b723223fa98 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 06:44:43 +0000 Subject: 05:24:49 - [PRESENCE]: Logging off 888760cb-a3cf-43ac-8ea4-8732fd3ee2bb because the region they were in has gone Or, in other words, a region crash/restart no longer messes up presence. --- OpenSim/Grid/MessagingServer/Main.cs | 1 + OpenSim/Grid/MessagingServer/MessageService.cs | 30 ++++++++++++ OpenSim/Grid/UserServer/Main.cs | 18 ++++++++ OpenSim/Grid/UserServer/MessageServersConnector.cs | 53 +++++++++++++++++++++- OpenSim/Grid/UserServer/UserManager.cs | 4 ++ 5 files changed, 105 insertions(+), 1 deletion(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 5568f73..0e03df1 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -90,6 +90,7 @@ namespace OpenSim.Grid.MessagingServer m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); m_httpServer.AddXmlRPCHandler("region_startup", msgsvc.RegionStartup); m_httpServer.AddXmlRPCHandler("region_shutdown", msgsvc.RegionShutdown); + m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index a4e54c7..a8ee9d5 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -666,5 +666,35 @@ namespace OpenSim.Grid.MessagingServer response.Value = result; return response; } + + public XmlRpcResponse ProcessRegionShutdown(XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable result = new Hashtable(); + result["success"] = "FALSE"; + + UUID regionID; + if (UUID.TryParse((string)requestData["regionid"], out regionID)) + { + m_log.DebugFormat("[PRESENCE] Processing region restart for {0}", regionID); + result["success"] = "TRUE"; + + foreach (UserPresenceData up in m_presences.Values) + { + if(up.regionData.UUID == regionID) + { + if (up.OnlineYN) + { + m_log.DebugFormat("[PRESENCE] Logging off {0} because the region they were in has gone", up.agentData.AgentID); + ProcessLogOff(up.agentData.AgentID); + } + } + } + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = result; + return response; + } } } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index f894ca0..4e397aa 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -464,12 +464,30 @@ namespace OpenSim.Grid.UserServer public void HandleRegionStartup(UUID regionID) { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // m_userManager.HandleRegionStartup(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); } public void HandleRegionShutdown(UUID regionID) { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // m_userManager.HandleRegionShutdown(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); } } } diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 6659617..6da67d7 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs @@ -259,6 +259,25 @@ namespace OpenSim.Grid.UserServer } } + private void TellMessageServersAboutRegionShutdownInternal(UUID regionID) + { + lock (MessageServers) + { + if (MessageServers.Count > 0) + { + m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers"); + } + else + { +// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); + } + foreach (MessageServerInfo serv in MessageServers.Values) + { + NotifyMessageServerAboutRegionShutdown(serv,regionID); + } + } + } + public void TellMessageServersAboutUserLogoff(UUID agentID) { PresenceNotification notification = new PresenceNotification(); @@ -269,6 +288,16 @@ namespace OpenSim.Grid.UserServer m_NotifyQueue.Enqueue(notification); } + public void TellMessageServersAboutRegionShutdown(UUID regionID) + { + PresenceNotification notification = new PresenceNotification(); + + notification.request = NotificationRequest.Shutdown; + notification.RegionID = regionID; + + m_NotifyQueue.Enqueue(notification); + } + private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) { Hashtable reqparams = new Hashtable(); @@ -289,6 +318,26 @@ namespace OpenSim.Grid.UserServer m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); } + private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID) + { + Hashtable reqparams = new Hashtable(); + reqparams["sendkey"] = serv.sendkey; + reqparams["regionid"] = regionID.ToString(); + ArrayList SendParams = new ArrayList(); + SendParams.Add(reqparams); + + XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams); + try + { + GridReq.Send(serv.URI, 6000); + } + catch (WebException) + { + m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown."); + } + m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change"); + } + private void NotifyMessageServerAboutUser(MessageServerInfo serv, UUID agentID, UUID sessionID, UUID RegionID, ulong regionhandle, float positionX, float positionY, float positionZ, @@ -331,7 +380,9 @@ namespace OpenSim.Grid.UserServer PresenceNotification presence = m_NotifyQueue.Dequeue(); if (presence.request == NotificationRequest.Shutdown) - return; + { + TellMessageServersAboutRegionShutdownInternal(presence.RegionID); + } if (presence.request == NotificationRequest.Login) { diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 04510b2..f8f9f39 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -790,6 +790,10 @@ namespace OpenSim.Grid.UserServer userProfile.LastLogin = userAgent.LogoutTime; CommitAgent(ref userProfile); + + handlerLogOffUser = OnLogOffUser; + if (handlerLogOffUser != null) + handlerLogOffUser(agentID); } } } -- cgit v1.1