From c66a9a08e4fed5cc675aac8a7a2999549049d79c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 8 Jul 2013 08:41:18 -0700 Subject: Placed a throttle on UserManagementModule for name lookups. Singularity apparently is flooding the sims with name requests. --- .../UserManagement/HGUserManagementModule.cs | 2 +- .../UserManagement/UserManagementModule.cs | 66 ++++++++++++++++++---- 2 files changed, 57 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index ad3cf15..245c808 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (umanmod == Name) { m_Enabled = true; - RegisterConsoleCmds(); + Init(); m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); } } diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 524d159..a528093 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -28,9 +28,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Threading; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; using OpenSim.Region.ClientStack.LindenUDP; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; @@ -57,6 +59,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // The cache protected Dictionary m_UserCache = new Dictionary(); + // Throttle the name requests + private OpenSim.Framework.BlockingQueue m_RequestQueue = new OpenSim.Framework.BlockingQueue(); + + #region ISharedRegionModule public void Initialise(IConfigSource config) @@ -65,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement if (umanmod == Name) { m_Enabled = true; - RegisterConsoleCmds(); + Init(); m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); } } @@ -160,16 +166,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } else { - string[] names; - bool foundRealName = TryGetUserNames(uuid, out names); + NameRequest request = new NameRequest(remote_client, uuid); + m_RequestQueue.Enqueue(request); - if (names.Length == 2) - { - if (!foundRealName) - m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], uuid, remote_client.Name); - - remote_client.SendNameReply(uuid, names[0], names[1]); - } } } @@ -596,6 +595,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement #endregion IUserManagement + protected void Init() + { + RegisterConsoleCmds(); + Watchdog.StartThread( + ProcessQueue, + "NameRequestThread", + ThreadPriority.BelowNormal, + true, + false); + + } + protected void RegisterConsoleCmds() { MainConsole.Instance.Commands.AddCommand("Users", true, @@ -662,5 +673,40 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement MainConsole.Instance.Output(cdt.ToString()); } + + private void ProcessQueue() + { + while (true) + { + Watchdog.UpdateThread(); + + NameRequest request = m_RequestQueue.Dequeue(); + string[] names; + bool foundRealName = TryGetUserNames(request.uuid, out names); + + if (names.Length == 2) + { + if (!foundRealName) + m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], request.uuid, request.client.Name); + + request.client.SendNameReply(request.uuid, names[0], names[1]); + } + + } + } + + } + + class NameRequest + { + public IClientAPI client; + public UUID uuid; + + public NameRequest(IClientAPI c, UUID n) + { + client = c; + uuid = n; + } } + } \ No newline at end of file -- cgit v1.1