From 765fd024183aa855b50ce9c9707abebba55ca63a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 4 Feb 2015 17:04:59 +0000 Subject: [PATCH] For built-in groups, if a delegate throws an exception (e.g. due to network failure), always remove its request from the m_ActiveRequests list. If this is not done, all subsequent calls for the same data see that a request is apparantly already in progress and so wait for the result indefinitely. --- .../Groups/RemoteConnectorCacheWrapper.cs | 197 ++++++++++++------ 1 file changed, 128 insertions(+), 69 deletions(-) diff --git a/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs b/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs index f121737d82..813f79658e 100644 --- a/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs +++ b/OpenSim/Addons/Groups/RemoteConnectorCacheWrapper.cs @@ -145,14 +145,20 @@ namespace OpenSim.Groups if (firstCall) { - //group = m_GroupsService.GetGroupRecord(RequestingAgentID, GroupID, GroupName); - group = d(); - - lock (m_Cache) + try + { + //group = m_GroupsService.GetGroupRecord(RequestingAgentID, GroupID, GroupName); + group = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, group, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupRecord)group; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, group, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupRecord)group; } } else @@ -244,13 +250,19 @@ namespace OpenSim.Groups if (firstCall) { - membership = d(); - - lock (m_Cache) + try + { + membership = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupMembershipData)membership; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupMembershipData)membership; } } else @@ -287,12 +299,18 @@ namespace OpenSim.Groups if (firstCall) { - membership = d(); - lock (m_Cache) + try + { + membership = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); + return (ExtendedGroupMembershipData)membership; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, membership, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (ExtendedGroupMembershipData)membership; } } else @@ -328,12 +346,18 @@ namespace OpenSim.Groups if (firstCall) { - memberships = d(); - lock (m_Cache) + try + { + memberships = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, memberships, GROUPS_CACHE_TIMEOUT); + return (List)memberships; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, memberships, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)memberships; } } else @@ -370,20 +394,26 @@ namespace OpenSim.Groups if (firstCall) { - List _members = d(); - - if (_members != null && _members.Count > 0) - members = _members.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupMembersData)); - else - members = new List(); - - lock (m_Cache) + try { - //m_Cache.AddOrUpdate(cacheKey, members, GROUPS_CACHE_TIMEOUT); - m_Cache.AddOrUpdate(cacheKey, _members, GROUPS_CACHE_TIMEOUT); - m_ActiveRequests.Remove(cacheKey); + List _members = d(); - return (List)members; + if (_members != null && _members.Count > 0) + members = _members.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupMembersData)); + else + members = new List(); + + lock (m_Cache) + { + //m_Cache.AddOrUpdate(cacheKey, members, GROUPS_CACHE_TIMEOUT); + m_Cache.AddOrUpdate(cacheKey, _members, GROUPS_CACHE_TIMEOUT); + + return (List)members; + } + } + finally + { + m_ActiveRequests.Remove(cacheKey); } } else @@ -498,16 +528,22 @@ namespace OpenSim.Groups if (firstCall) { - roles = d(); - if (roles != null) + try { - lock (m_Cache) + roles = d(); + if (roles != null) { - m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); - m_ActiveRequests.Remove(cacheKey); - return (List)roles; + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); + return (List)roles; + } } } + finally + { + m_ActiveRequests.Remove(cacheKey); + } } else Thread.Sleep(50); @@ -542,23 +578,29 @@ namespace OpenSim.Groups if (firstCall) { - List _rmembers = d(); - - if (_rmembers != null && _rmembers.Count > 0) - rmembers = _rmembers.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupRoleMembersData)); - else - rmembers = new List(); - - lock (m_Cache) + try + { + List _rmembers = d(); + + if (_rmembers != null && _rmembers.Count > 0) + rmembers = _rmembers.ConvertAll(new Converter(m_ForeignImporter.ConvertGroupRoleMembersData)); + else + rmembers = new List(); + + lock (m_Cache) + { + // For some strange reason, when I cache the list of GroupRoleMembersData, + // it gets emptied out. The TryGet gets an empty list... + //m_Cache.AddOrUpdate(cacheKey, rmembers, GROUPS_CACHE_TIMEOUT); + // Caching the list of ExtendedGroupRoleMembersData doesn't show that issue + // I don't get it. + m_Cache.AddOrUpdate(cacheKey, _rmembers, GROUPS_CACHE_TIMEOUT); + return (List)rmembers; + } + } + finally { - // For some strange reason, when I cache the list of GroupRoleMembersData, - // it gets emptied out. The TryGet gets an empty list... - //m_Cache.AddOrUpdate(cacheKey, rmembers, GROUPS_CACHE_TIMEOUT); - // Caching the list of ExtendedGroupRoleMembersData doesn't show that issue - // I don't get it. - m_Cache.AddOrUpdate(cacheKey, _rmembers, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)rmembers; } } else @@ -667,12 +709,19 @@ namespace OpenSim.Groups if (firstCall) { - roles = d(); - lock (m_Cache) + try + { + roles = d(); + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); + m_ActiveRequests.Remove(cacheKey); + return (List)roles; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, roles, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)roles; } } else @@ -768,13 +817,19 @@ namespace OpenSim.Groups if (firstCall) { - GroupNoticeInfo _notice = d(); - - lock (m_Cache) + try + { + GroupNoticeInfo _notice = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, _notice, GROUPS_CACHE_TIMEOUT); + return _notice; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, _notice, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return _notice; } } else @@ -810,20 +865,24 @@ namespace OpenSim.Groups if (firstCall) { - notices = d(); - - lock (m_Cache) + try + { + notices = d(); + + lock (m_Cache) + { + m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); + return (List)notices; + } + } + finally { - m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); m_ActiveRequests.Remove(cacheKey); - return (List)notices; } } else Thread.Sleep(50); } } - - } -} +} \ No newline at end of file