diff options
author | Diva Canto | 2013-07-16 17:04:32 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-16 17:04:32 -0700 |
commit | 3fbd2c54bc7357ea61b3a8b0c56473ae6a5a3260 (patch) | |
tree | 9f1781032c42341bad69d720ae93f0e04b30f0d2 | |
parent | In the pursuit of using less CPU: now trying to avoid blocking queues altoget... (diff) | |
download | opensim-SC_OLD-3fbd2c54bc7357ea61b3a8b0c56473ae6a5a3260.zip opensim-SC_OLD-3fbd2c54bc7357ea61b3a8b0c56473ae6a5a3260.tar.gz opensim-SC_OLD-3fbd2c54bc7357ea61b3a8b0c56473ae6a5a3260.tar.bz2 opensim-SC_OLD-3fbd2c54bc7357ea61b3a8b0c56473ae6a5a3260.tar.xz |
Eliminated the UserManagement/UserManagementModule throttle thread. Made the other one generic, taking any continuation.
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs | 160 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 177 |
2 files changed, 148 insertions, 189 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs index 83be644..d805fd3 100644 --- a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs | |||
@@ -42,7 +42,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | namespace OpenSim.Region.CoreModules.Framework | 42 | namespace OpenSim.Region.CoreModules.Framework |
43 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridServiceThrottleModule")] | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridServiceThrottleModule")] |
45 | public class GridServiceThrottleModule : ISharedRegionModule | 45 | public class ServiceThrottleModule : ISharedRegionModule, IServiceThrottleModule |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger( | 47 | private static readonly ILog m_log = LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | MethodBase.GetCurrentMethod().DeclaringType); |
@@ -52,12 +52,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
52 | 52 | ||
53 | //private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); | 53 | //private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); |
54 | // private OpenSim.Framework.DoubleQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<GridRegionRequest>(); | 54 | // private OpenSim.Framework.DoubleQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<GridRegionRequest>(); |
55 | private Queue<GridRegionRequest> m_RequestQueue = new Queue<GridRegionRequest>(); | 55 | //private Queue<GridRegionRequest> m_RequestQueue = new Queue<GridRegionRequest>(); |
56 | private Queue<Action> m_RequestQueue = new Queue<Action>(); | ||
57 | |||
58 | #region ISharedRegionModule | ||
56 | 59 | ||
57 | public void Initialise(IConfigSource config) | 60 | public void Initialise(IConfigSource config) |
58 | { | 61 | { |
59 | m_timer = new System.Timers.Timer(); | 62 | m_timer = new System.Timers.Timer(); |
60 | m_timer.AutoReset = false; | 63 | m_timer.AutoReset = false; |
64 | m_timer.Enabled = true; | ||
61 | m_timer.Interval = 15000; // 15 secs at first | 65 | m_timer.Interval = 15000; // 15 secs at first |
62 | m_timer.Elapsed += ProcessQueue; | 66 | m_timer.Elapsed += ProcessQueue; |
63 | m_timer.Start(); | 67 | m_timer.Start(); |
@@ -75,7 +79,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
75 | lock (m_scenes) | 79 | lock (m_scenes) |
76 | { | 80 | { |
77 | m_scenes.Add(scene); | 81 | m_scenes.Add(scene); |
82 | scene.RegisterModuleInterface<IServiceThrottleModule>(this); | ||
78 | scene.EventManager.OnNewClient += OnNewClient; | 83 | scene.EventManager.OnNewClient += OnNewClient; |
84 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
79 | } | 85 | } |
80 | } | 86 | } |
81 | 87 | ||
@@ -92,21 +98,6 @@ namespace OpenSim.Region.CoreModules.Framework | |||
92 | } | 98 | } |
93 | } | 99 | } |
94 | 100 | ||
95 | void OnNewClient(IClientAPI client) | ||
96 | { | ||
97 | client.OnRegionHandleRequest += OnRegionHandleRequest; | ||
98 | } | ||
99 | |||
100 | //void OnMakeRootAgent(ScenePresence obj) | ||
101 | //{ | ||
102 | // lock (m_timer) | ||
103 | // { | ||
104 | // m_timer.Stop(); | ||
105 | // m_timer.Interval = 1000; | ||
106 | // m_timer.Start(); | ||
107 | // } | ||
108 | //} | ||
109 | |||
110 | public void PostInitialise() | 101 | public void PostInitialise() |
111 | { | 102 | { |
112 | } | 103 | } |
@@ -117,7 +108,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
117 | 108 | ||
118 | public string Name | 109 | public string Name |
119 | { | 110 | { |
120 | get { return "GridServiceThrottleModule"; } | 111 | get { return "ServiceThrottleModule"; } |
121 | } | 112 | } |
122 | 113 | ||
123 | public Type ReplaceableInterface | 114 | public Type ReplaceableInterface |
@@ -125,9 +116,31 @@ namespace OpenSim.Region.CoreModules.Framework | |||
125 | get { return null; } | 116 | get { return null; } |
126 | } | 117 | } |
127 | 118 | ||
119 | #endregion ISharedRegionMOdule | ||
120 | |||
121 | #region Events | ||
122 | |||
123 | void OnNewClient(IClientAPI client) | ||
124 | { | ||
125 | client.OnRegionHandleRequest += OnRegionHandleRequest; | ||
126 | } | ||
127 | |||
128 | void OnMakeRootAgent(ScenePresence obj) | ||
129 | { | ||
130 | lock (m_timer) | ||
131 | { | ||
132 | if (!m_timer.Enabled) | ||
133 | { | ||
134 | m_timer.Interval = 1000; | ||
135 | m_timer.Enabled = true; | ||
136 | m_timer.Start(); | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | |||
128 | public void OnRegionHandleRequest(IClientAPI client, UUID regionID) | 141 | public void OnRegionHandleRequest(IClientAPI client, UUID regionID) |
129 | { | 142 | { |
130 | //m_log.DebugFormat("[GRIDSERVICE THROTTLE]: RegionHandleRequest {0}", regionID); | 143 | //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID); |
131 | ulong handle = 0; | 144 | ulong handle = 0; |
132 | if (IsLocalRegionHandle(regionID, out handle)) | 145 | if (IsLocalRegionHandle(regionID, out handle)) |
133 | { | 146 | { |
@@ -135,87 +148,90 @@ namespace OpenSim.Region.CoreModules.Framework | |||
135 | return; | 148 | return; |
136 | } | 149 | } |
137 | 150 | ||
138 | GridRegionRequest request = new GridRegionRequest(client, regionID); | 151 | Action action = delegate |
152 | { | ||
153 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID); | ||
154 | |||
155 | if (r != null && r.RegionHandle != 0) | ||
156 | client.SendRegionHandle(regionID, r.RegionHandle); | ||
157 | }; | ||
158 | |||
139 | lock (m_RequestQueue) | 159 | lock (m_RequestQueue) |
140 | m_RequestQueue.Enqueue(request); | 160 | m_RequestQueue.Enqueue(action); |
141 | 161 | ||
142 | } | 162 | } |
143 | 163 | ||
144 | private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle) | 164 | #endregion Events |
165 | |||
166 | #region IServiceThrottleModule | ||
167 | |||
168 | public void Enqueue(Action continuation) | ||
145 | { | 169 | { |
146 | regionHandle = 0; | 170 | m_RequestQueue.Enqueue(continuation); |
147 | foreach (Scene s in m_scenes) | ||
148 | if (s.RegionInfo.RegionID == regionID) | ||
149 | { | ||
150 | regionHandle = s.RegionInfo.RegionHandle; | ||
151 | return true; | ||
152 | } | ||
153 | return false; | ||
154 | } | 171 | } |
155 | 172 | ||
156 | private bool AreThereRootAgents() | 173 | #endregion IServiceThrottleModule |
157 | { | ||
158 | foreach (Scene s in m_scenes) | ||
159 | { | ||
160 | if (s.GetRootAgentCount() > 0) | ||
161 | return true; | ||
162 | } | ||
163 | 174 | ||
164 | return false; | 175 | #region Process Continuation Queue |
165 | } | ||
166 | 176 | ||
167 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) | 177 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) |
168 | { | 178 | { |
179 | m_log.DebugFormat("[YYY]: Process queue with {0} continuations", m_RequestQueue.Count); | ||
180 | |||
169 | while (m_RequestQueue.Count > 0) | 181 | while (m_RequestQueue.Count > 0) |
170 | { | 182 | { |
171 | GridRegionRequest request = null; | 183 | Action continuation = null; |
172 | lock (m_RequestQueue) | 184 | lock (m_RequestQueue) |
173 | request = m_RequestQueue.Dequeue(); | 185 | continuation = m_RequestQueue.Dequeue(); |
174 | if (request != null) | ||
175 | { | ||
176 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID); | ||
177 | 186 | ||
178 | if (r != null && r.RegionHandle != 0) | 187 | if (continuation != null) |
179 | request.client.SendRegionHandle(request.regionID, r.RegionHandle); | 188 | continuation(); |
180 | } | ||
181 | } | 189 | } |
182 | 190 | ||
183 | if (AreThereRootAgents()) | 191 | if (AreThereRootAgents()) |
184 | m_timer.Interval = 1000; // 1 sec | 192 | { |
193 | lock (m_timer) | ||
194 | { | ||
195 | m_timer.Interval = 1000; // 1 sec | ||
196 | m_timer.Enabled = true; | ||
197 | m_timer.Start(); | ||
198 | } | ||
199 | } | ||
185 | else | 200 | else |
186 | m_timer.Interval = 10000; // 10 secs | 201 | lock (m_timer) |
202 | m_timer.Enabled = false; | ||
187 | 203 | ||
188 | m_timer.Start(); | ||
189 | } | 204 | } |
190 | 205 | ||
191 | private void ProcessQueue() | 206 | #endregion Process Continuation Queue |
192 | { | ||
193 | while (true) | ||
194 | { | ||
195 | Watchdog.UpdateThread(); | ||
196 | 207 | ||
197 | GridRegionRequest request = m_RequestQueue.Dequeue(); | 208 | #region Misc |
198 | if (request != null) | ||
199 | { | ||
200 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID); | ||
201 | 209 | ||
202 | if (r != null && r.RegionHandle != 0) | 210 | private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle) |
203 | request.client.SendRegionHandle(request.regionID, r.RegionHandle); | 211 | { |
212 | regionHandle = 0; | ||
213 | foreach (Scene s in m_scenes) | ||
214 | if (s.RegionInfo.RegionID == regionID) | ||
215 | { | ||
216 | regionHandle = s.RegionInfo.RegionHandle; | ||
217 | return true; | ||
204 | } | 218 | } |
205 | } | 219 | return false; |
206 | } | 220 | } |
207 | 221 | ||
208 | } | 222 | private bool AreThereRootAgents() |
209 | |||
210 | class GridRegionRequest | ||
211 | { | ||
212 | public IClientAPI client; | ||
213 | public UUID regionID; | ||
214 | |||
215 | public GridRegionRequest(IClientAPI c, UUID r) | ||
216 | { | 223 | { |
217 | client = c; | 224 | foreach (Scene s in m_scenes) |
218 | regionID = r; | 225 | { |
226 | foreach (ScenePresence sp in s.GetScenePresences()) | ||
227 | if (!sp.IsChildAgent) | ||
228 | return true; | ||
229 | } | ||
230 | |||
231 | return false; | ||
219 | } | 232 | } |
233 | |||
234 | #endregion Misc | ||
220 | } | 235 | } |
236 | |||
221 | } | 237 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 61c1e70..73b59d3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -56,16 +56,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
56 | protected bool m_Enabled; | 56 | protected bool m_Enabled; |
57 | protected List<Scene> m_Scenes = new List<Scene>(); | 57 | protected List<Scene> m_Scenes = new List<Scene>(); |
58 | 58 | ||
59 | protected IServiceThrottleModule m_ServiceThrottle; | ||
59 | // The cache | 60 | // The cache |
60 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); | 61 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); |
61 | 62 | ||
62 | // Throttle the name requests | ||
63 | //private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>(); | ||
64 | //private OpenSim.Framework.DoubleQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<NameRequest>(); | ||
65 | private Queue<NameRequest> m_RequestQueue = new Queue<NameRequest>(); | ||
66 | |||
67 | private System.Timers.Timer m_timer; | ||
68 | |||
69 | #region ISharedRegionModule | 63 | #region ISharedRegionModule |
70 | 64 | ||
71 | public void Initialise(IConfigSource config) | 65 | public void Initialise(IConfigSource config) |
@@ -118,6 +112,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
118 | 112 | ||
119 | public void RegionLoaded(Scene s) | 113 | public void RegionLoaded(Scene s) |
120 | { | 114 | { |
115 | if (m_Enabled && m_ServiceThrottle == null) | ||
116 | m_ServiceThrottle = s.RequestModuleInterface<IServiceThrottleModule>(); | ||
121 | } | 117 | } |
122 | 118 | ||
123 | public void PostInitialise() | 119 | public void PostInitialise() |
@@ -157,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
157 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); | 153 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); |
158 | } | 154 | } |
159 | 155 | ||
160 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | 156 | void HandleUUIDNameRequest(UUID uuid, IClientAPI client) |
161 | { | 157 | { |
162 | // m_log.DebugFormat( | 158 | // m_log.DebugFormat( |
163 | // "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}", | 159 | // "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}", |
@@ -165,12 +161,33 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
165 | 161 | ||
166 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) | 162 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) |
167 | { | 163 | { |
168 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | 164 | client.SendNameReply(uuid, "Mr", "OpenSim"); |
169 | } | 165 | } |
170 | else | 166 | else |
171 | { | 167 | { |
172 | NameRequest request = new NameRequest(remote_client, uuid); | 168 | string[] names = new string[2]; |
173 | m_RequestQueue.Enqueue(request); | 169 | if (TryGetUserNamesFromCache(uuid, names)) |
170 | { | ||
171 | client.SendNameReply(uuid, names[0], names[1]); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | // Not found in cache, get it from services | ||
176 | m_ServiceThrottle.Enqueue(delegate | ||
177 | { | ||
178 | m_log.DebugFormat("[YYY]: Name request {0}", uuid); | ||
179 | bool foundRealName = TryGetUserNamesFromServices(uuid, names); | ||
180 | |||
181 | if (names.Length == 2) | ||
182 | { | ||
183 | if (!foundRealName) | ||
184 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], uuid, client.Name); | ||
185 | else | ||
186 | m_log.DebugFormat("[YYY]: Found user {0} {1} for uuid {2}", names[0], names[1], uuid); | ||
187 | |||
188 | client.SendNameReply(uuid, names[0], names[1]); | ||
189 | } | ||
190 | }); | ||
174 | 191 | ||
175 | } | 192 | } |
176 | } | 193 | } |
@@ -286,15 +303,27 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
286 | } | 303 | } |
287 | 304 | ||
288 | /// <summary> | 305 | /// <summary> |
289 | /// Try to get the names bound to the given uuid. | 306 | /// |
290 | /// </summary> | 307 | /// </summary> |
291 | /// <returns>True if the name was found, false if not.</returns> | 308 | /// <param name="uuid"></param> |
292 | /// <param name='uuid'></param> | 309 | /// <param name="names">Caller please provide a properly instantiated array for names, string[2]</param> |
293 | /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> | 310 | /// <returns></returns> |
294 | private bool TryGetUserNames(UUID uuid, out string[] names) | 311 | private bool TryGetUserNames(UUID uuid, string[] names) |
295 | { | 312 | { |
296 | names = new string[2]; | 313 | if (names == null) |
314 | names = new string[2]; | ||
315 | |||
316 | if (TryGetUserNamesFromCache(uuid, names)) | ||
317 | return true; | ||
318 | |||
319 | if (TryGetUserNamesFromServices(uuid, names)) | ||
320 | return true; | ||
321 | |||
322 | return false; | ||
323 | } | ||
297 | 324 | ||
325 | private bool TryGetUserNamesFromCache(UUID uuid, string[] names) | ||
326 | { | ||
298 | lock (m_UserCache) | 327 | lock (m_UserCache) |
299 | { | 328 | { |
300 | if (m_UserCache.ContainsKey(uuid)) | 329 | if (m_UserCache.ContainsKey(uuid)) |
@@ -306,6 +335,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
306 | } | 335 | } |
307 | } | 336 | } |
308 | 337 | ||
338 | return false; | ||
339 | } | ||
340 | |||
341 | /// <summary> | ||
342 | /// Try to get the names bound to the given uuid, from the services. | ||
343 | /// </summary> | ||
344 | /// <returns>True if the name was found, false if not.</returns> | ||
345 | /// <param name='uuid'></param> | ||
346 | /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> | ||
347 | private bool TryGetUserNamesFromServices(UUID uuid, string[] names) | ||
348 | { | ||
309 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); | 349 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); |
310 | 350 | ||
311 | if (account != null) | 351 | if (account != null) |
@@ -390,18 +430,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
390 | 430 | ||
391 | public string GetUserName(UUID uuid) | 431 | public string GetUserName(UUID uuid) |
392 | { | 432 | { |
393 | string[] names; | 433 | string[] names = new string[2]; |
394 | TryGetUserNames(uuid, out names); | 434 | TryGetUserNames(uuid, names); |
395 | 435 | ||
396 | if (names.Length == 2) | 436 | return names[0] + " " + names[1]; |
397 | { | ||
398 | string firstname = names[0]; | ||
399 | string lastname = names[1]; | ||
400 | |||
401 | return firstname + " " + lastname; | ||
402 | } | ||
403 | 437 | ||
404 | return "(hippos)"; | ||
405 | } | 438 | } |
406 | 439 | ||
407 | public string GetUserHomeURL(UUID userID) | 440 | public string GetUserHomeURL(UUID userID) |
@@ -601,19 +634,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
601 | protected void Init() | 634 | protected void Init() |
602 | { | 635 | { |
603 | RegisterConsoleCmds(); | 636 | RegisterConsoleCmds(); |
604 | //Watchdog.StartThread( | ||
605 | // ProcessQueue, | ||
606 | // "NameRequestThread", | ||
607 | // ThreadPriority.BelowNormal, | ||
608 | // true, | ||
609 | // false); | ||
610 | |||
611 | m_timer = new System.Timers.Timer(); | ||
612 | m_timer.AutoReset = false; | ||
613 | m_timer.Interval = 15000; // 15 secs at first | ||
614 | m_timer.Elapsed += ProcessQueue; | ||
615 | m_timer.Start(); | ||
616 | |||
617 | } | 637 | } |
618 | 638 | ||
619 | protected void RegisterConsoleCmds() | 639 | protected void RegisterConsoleCmds() |
@@ -683,83 +703,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
683 | MainConsole.Instance.Output(cdt.ToString()); | 703 | MainConsole.Instance.Output(cdt.ToString()); |
684 | } | 704 | } |
685 | 705 | ||
686 | private void ProcessQueue() | ||
687 | { | ||
688 | while (true) | ||
689 | { | ||
690 | Watchdog.UpdateThread(); | ||
691 | |||
692 | NameRequest request = m_RequestQueue.Dequeue(); | ||
693 | if (request != null) | ||
694 | { | ||
695 | string[] names; | ||
696 | bool foundRealName = TryGetUserNames(request.uuid, out names); | ||
697 | |||
698 | if (names.Length == 2) | ||
699 | { | ||
700 | if (!foundRealName) | ||
701 | 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); | ||
702 | |||
703 | request.client.SendNameReply(request.uuid, names[0], names[1]); | ||
704 | } | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | |||
709 | private bool AreThereRootAgents() | ||
710 | { | ||
711 | foreach (Scene s in m_Scenes) | ||
712 | { | ||
713 | if (s.GetRootAgentCount() > 0) | ||
714 | return true; | ||
715 | } | ||
716 | |||
717 | return false; | ||
718 | } | ||
719 | |||
720 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) | ||
721 | { | ||
722 | while (m_RequestQueue.Count > 0) | ||
723 | { | ||
724 | NameRequest request = null; | ||
725 | lock (m_RequestQueue) | ||
726 | request = m_RequestQueue.Dequeue(); | ||
727 | |||
728 | if (request != null) | ||
729 | { | ||
730 | string[] names; | ||
731 | bool foundRealName = TryGetUserNames(request.uuid, out names); | ||
732 | |||
733 | if (names.Length == 2) | ||
734 | { | ||
735 | if (!foundRealName) | ||
736 | 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); | ||
737 | |||
738 | request.client.SendNameReply(request.uuid, names[0], names[1]); | ||
739 | } | ||
740 | } | ||
741 | } | ||
742 | |||
743 | if (AreThereRootAgents()) | ||
744 | m_timer.Interval = 1000; // 1 sec | ||
745 | else | ||
746 | m_timer.Interval = 10000; // 10 secs | ||
747 | |||
748 | m_timer.Start(); | ||
749 | |||
750 | } | ||
751 | } | ||
752 | |||
753 | class NameRequest | ||
754 | { | ||
755 | public IClientAPI client; | ||
756 | public UUID uuid; | ||
757 | |||
758 | public NameRequest(IClientAPI c, UUID n) | ||
759 | { | ||
760 | client = c; | ||
761 | uuid = n; | ||
762 | } | ||
763 | } | 706 | } |
764 | 707 | ||
765 | } \ No newline at end of file | 708 | } \ No newline at end of file |