From f5d82350bb622baa6f49042882e6c5cb49b24cc0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 7 Jun 2011 10:51:12 -0700 Subject: This fixes the crash reported in http://opensimulator.org/mantis/view.php?id=5529 related to sending IMs to foreign friends who are offline. Hopefully. --- .../InstantMessage/HGMessageTransferModule.cs | 8 ++++--- .../Handlers/Hypergrid/UserAgentServerConnector.cs | 24 +++++++++---------- .../HypergridService/HGInstantMessageService.cs | 28 ++++++++++------------ .../Services/HypergridService/UserAgentService.cs | 2 +- OpenSim/Services/Interfaces/IHypergridServices.cs | 2 +- 5 files changed, 31 insertions(+), 33 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index dee86df..7753c25 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -196,10 +196,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage Util.FireAndForget(delegate { - bool success = m_IMService.OutgoingInstantMessage(im, url, foreigner); - if (!success && account == null) + bool success = false; + if (foreigner && url == string.Empty) // we don't know about this user { - // One last chance string recipientUUI = TryGetRecipientUUI(new UUID(im.fromAgentID), toAgentID); m_log.DebugFormat("[HG MESSAGE TRANSFER]: Got UUI {0}", recipientUUI); if (recipientUUI != string.Empty) @@ -213,6 +212,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } } } + else + success = m_IMService.OutgoingInstantMessage(im, url, foreigner); + if (!success && !foreigner) HandleUndeliveredMessage(im, result); else diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs index 9961164..2022d8a 100644 --- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs @@ -268,18 +268,18 @@ namespace OpenSim.Server.Handlers.Hypergrid ids.Add(requestData[key].ToString()); } - List online = m_HomeUsersService.GetOnlineFriends(userID, ids); - if (online.Count > 0) - { - int i = 0; - foreach (UUID id in online) - { - hash["friend_" + i.ToString()] = id.ToString(); - i++; - } - } - else - hash["result"] = "No Friends Online"; + //List online = m_HomeUsersService.GetOnlineFriends(userID, ids); + //if (online.Count > 0) + //{ + // int i = 0; + // foreach (UUID id in online) + // { + // hash["friend_" + i.ToString()] = id.ToString(); + // i++; + // } + //} + //else + // hash["result"] = "No Friends Online"; } XmlRpcResponse response = new XmlRpcResponse(); diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index 66cf4de..90a0bf2 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -185,7 +185,6 @@ namespace OpenSim.Services.HypergridService { lookupAgent = true; upd = null; - url = string.Empty; } } else @@ -221,19 +220,16 @@ namespace OpenSim.Services.HypergridService url = m_UserAgentService.LocateUser(toAgentID); } - if (upd != null || url != string.Empty) + // check if we've tried this before.. + // This is one way to end the recursive loop + // + if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) || + (previousLocation is string && upd == null && previousLocation.Equals(url)))) { - // check if we've tried this before.. - // This is one way to end the recursive loop - // - if (!firstTime && ((previousLocation is PresenceInfo && upd != null && upd.RegionID == ((PresenceInfo)previousLocation).RegionID) || - (previousLocation is string && upd == null && previousLocation.Equals(url)))) - { - // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); - m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url); + // m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); + m_log.DebugFormat("[HG IM SERVICE]: Fail 2 {0} {1}", previousLocation, url); - return false; - } + return false; } } @@ -332,10 +328,6 @@ namespace OpenSim.Services.HypergridService else { // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC // This is recursive!!!!! return TrySendInstantMessage(im, url, false, foreigner); @@ -348,13 +340,17 @@ namespace OpenSim.Services.HypergridService if (m_RestURL != string.Empty && (im.offline != 0) && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) { + m_log.DebugFormat("[HG IM SERVICE]: Message saved"); return SynchronousRestObjectPoster.BeginPostObject( "POST", m_RestURL + "/SaveMessage/", im); } else + { + m_log.DebugFormat("[HG IM SERVICE]: No offline IM service, message not saved"); return false; + } } } } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 2f2ebfb..8d78f97 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -482,7 +482,7 @@ namespace OpenSim.Services.HypergridService { foreach (TravelingAgentInfo t in m_TravelingAgents.Values) { - if (t.UserID == userID) + if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName)) return t.GridExternalName; } diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 82ec8ce..3c6fedf 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -62,7 +62,7 @@ namespace OpenSim.Services.Interfaces string GetUUI(UUID userID, UUID targetUserID); void StatusNotification(List friends, UUID userID, bool online); - List GetOnlineFriends(UUID userID, List friends); + //List GetOnlineFriends(UUID userID, List friends); bool AgentIsComingHome(UUID sessionID, string thisGridExternalName); bool VerifyAgent(UUID sessionID, string token); -- cgit v1.1