diff --git a/OpenSim/Framework/VersionInfo.cs b/OpenSim/Framework/VersionInfo.cs index a1ba2aa5fe..f0f1eb43c3 100644 --- a/OpenSim/Framework/VersionInfo.cs +++ b/OpenSim/Framework/VersionInfo.cs @@ -75,7 +75,7 @@ namespace OpenSim /// The protocol version that we will use for outgoing transfers /// Valid values are /// "SIMULATION/0.3" - /// - This is the latest, and it supports teleports to variable-sized regions + /// - supports teleports to variable-sized regions /// - Older versions can teleport to this one, but only if the destination region /// is 256x256 /// "SIMULATION/0.2" diff --git a/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs index 8a44ba46bc..583e45df3c 100644 --- a/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs @@ -60,6 +60,9 @@ namespace OpenSim.Region.CoreModules.Framework.Search private IGroupsModule m_GroupsService = null; + private ExpiringCache> queryPeopleCache = new ExpiringCache>(); + private ExpiringCache> queryGroupCache = new ExpiringCache>(); + #region ISharedRegionModule public void Initialise(IConfigSource config) @@ -150,16 +153,31 @@ namespace OpenSim.Region.CoreModules.Framework.Search void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) { - queryText = queryText.Trim(); + if (!string.IsNullOrEmpty(queryText)) + { + queryText = queryText.Trim(); + queryText = queryText.ToLowerInvariant(); + } if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People) { if (string.IsNullOrEmpty(queryText)) remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]); - List accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText); + List accounts; + if (!queryPeopleCache.TryGetValue(queryText, out accounts)) + accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText); + + queryPeopleCache.AddOrUpdate(queryText, accounts, 30.0); + + if (accounts.Count == 0) + { + remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]); + return; + } + DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count]; - int i = 0; + int count = 0; foreach (UserAccount acc in accounts) { DirPeopleReplyData d = new DirPeopleReplyData(); @@ -168,9 +186,25 @@ namespace OpenSim.Region.CoreModules.Framework.Search d.lastName = acc.LastName; d.online = false; - hits[i++] = d; + hits[count++] = d; } + // viewers don't sent sorting, so results they show are a nice mess + if ((queryStart > 0) && (queryStart < count)) + { + int len = count - queryStart; + if (len > 101) // a viewer page is 100 + len = 101; + DirPeopleReplyData[] tmp = new DirPeopleReplyData[len]; + Array.Copy(hits, queryStart, tmp, 0, len); + hits = tmp; + } + else if (count > 101) + { + DirPeopleReplyData[] tmp = new DirPeopleReplyData[101]; + Array.Copy(hits, 0, tmp, 0, 101); + hits = tmp; + } // TODO: This currently ignores pretty much all the query flags including Mature and sort order remoteClient.SendDirPeopleReply(queryID, hits); } @@ -186,7 +220,12 @@ namespace OpenSim.Region.CoreModules.Framework.Search if (string.IsNullOrEmpty(queryText)) remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]); - List answer = m_GroupsService.FindGroups(remoteClient, queryText); + List answer; + if (!queryGroupCache.TryGetValue(queryText, out answer)) + answer = m_GroupsService.FindGroups(remoteClient, queryText); + + queryGroupCache.AddOrUpdate(queryText, answer, 30.0); + if(answer.Count == 0) { remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);