diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
8 files changed, 560 insertions, 79 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index fff86d5..3d5ed4f 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
33 | using log4net; | 34 | using log4net; |
@@ -37,6 +38,7 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Servers; | 40 | using OpenSim.Framework.Servers; |
41 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
42 | using Caps=OpenSim.Framework.Capabilities.Caps; | 44 | using Caps=OpenSim.Framework.Capabilities.Caps; |
@@ -57,8 +59,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
57 | /// </summary> | 59 | /// </summary> |
58 | protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); | 60 | protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); |
59 | 61 | ||
60 | protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); | 62 | protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); |
61 | protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds | 63 | |
64 | protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds | ||
62 | = new Dictionary<UUID, Dictionary<ulong, string>>(); | 65 | = new Dictionary<UUID, Dictionary<ulong, string>>(); |
63 | 66 | ||
64 | public void Initialise(IConfigSource source) | 67 | public void Initialise(IConfigSource source) |
@@ -70,9 +73,24 @@ namespace OpenSim.Region.CoreModules.Framework | |||
70 | m_scene = scene; | 73 | m_scene = scene; |
71 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); | 74 | m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); |
72 | 75 | ||
73 | MainConsole.Instance.Commands.AddCommand("Comms", false, "show caps", | 76 | MainConsole.Instance.Commands.AddCommand( |
74 | "show caps", | 77 | "Comms", false, "show caps list", |
75 | "Shows all registered capabilities for users", HandleShowCapsCommand); | 78 | "show caps list", |
79 | "Shows list of registered capabilities for users.", HandleShowCapsListCommand); | ||
80 | |||
81 | MainConsole.Instance.Commands.AddCommand( | ||
82 | "Comms", false, "show caps stats by user", | ||
83 | "show caps stats [<first-name> <last-name>]", | ||
84 | "Shows statistics on capabilities use by user.", | ||
85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", | ||
86 | HandleShowCapsStatsByUserCommand); | ||
87 | |||
88 | MainConsole.Instance.Commands.AddCommand( | ||
89 | "Comms", false, "show caps stats by cap", | ||
90 | "show caps stats by cap [<cap-name>]", | ||
91 | "Shows statistics on capabilities use by capability.", | ||
92 | "If a capability name is given, then prints a detailed breakdown of use by each user.", | ||
93 | HandleShowCapsStatsByCapCommand); | ||
76 | } | 94 | } |
77 | 95 | ||
78 | public void RegionLoaded(Scene scene) | 96 | public void RegionLoaded(Scene scene) |
@@ -106,35 +124,42 @@ namespace OpenSim.Region.CoreModules.Framework | |||
106 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) | 124 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) |
107 | return; | 125 | return; |
108 | 126 | ||
127 | Caps caps; | ||
109 | String capsObjectPath = GetCapsPath(agentId); | 128 | String capsObjectPath = GetCapsPath(agentId); |
110 | 129 | ||
111 | if (m_capsObjects.ContainsKey(circuitCode)) | 130 | lock (m_capsObjects) |
112 | { | 131 | { |
113 | Caps oldCaps = m_capsObjects[circuitCode]; | 132 | if (m_capsObjects.ContainsKey(circuitCode)) |
114 | 133 | { | |
115 | m_log.DebugFormat( | 134 | Caps oldCaps = m_capsObjects[circuitCode]; |
116 | "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", | 135 | |
117 | agentId, oldCaps.CapsObjectPath, capsObjectPath); | 136 | m_log.DebugFormat( |
118 | // This should not happen. The caller code is confused. We need to fix that. | 137 | "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", |
119 | // CAPs can never be reregistered, or the client will be confused. | 138 | agentId, oldCaps.CapsObjectPath, capsObjectPath); |
120 | // Hence this return here. | 139 | // This should not happen. The caller code is confused. We need to fix that. |
121 | //return; | 140 | // CAPs can never be reregistered, or the client will be confused. |
122 | } | 141 | // Hence this return here. |
142 | //return; | ||
143 | } | ||
123 | 144 | ||
124 | Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, | 145 | caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, |
125 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | 146 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, |
126 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); | 147 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); |
127 | 148 | ||
128 | m_capsObjects[circuitCode] = caps; | 149 | m_capsObjects[circuitCode] = caps; |
150 | } | ||
129 | 151 | ||
130 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | 152 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); |
131 | } | 153 | } |
132 | 154 | ||
133 | public void RemoveCaps(UUID agentId, uint circuitCode) | 155 | public void RemoveCaps(UUID agentId, uint circuitCode) |
134 | { | 156 | { |
135 | if (childrenSeeds.ContainsKey(agentId)) | 157 | lock (m_childrenSeeds) |
136 | { | 158 | { |
137 | childrenSeeds.Remove(agentId); | 159 | if (m_childrenSeeds.ContainsKey(agentId)) |
160 | { | ||
161 | m_childrenSeeds.Remove(agentId); | ||
162 | } | ||
138 | } | 163 | } |
139 | 164 | ||
140 | lock (m_capsObjects) | 165 | lock (m_capsObjects) |
@@ -180,16 +205,22 @@ namespace OpenSim.Region.CoreModules.Framework | |||
180 | 205 | ||
181 | public void SetAgentCapsSeeds(AgentCircuitData agent) | 206 | public void SetAgentCapsSeeds(AgentCircuitData agent) |
182 | { | 207 | { |
183 | capsPaths[agent.AgentID] = agent.CapsPath; | 208 | lock (m_capsPaths) |
184 | childrenSeeds[agent.AgentID] | 209 | m_capsPaths[agent.AgentID] = agent.CapsPath; |
185 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | 210 | |
211 | lock (m_childrenSeeds) | ||
212 | m_childrenSeeds[agent.AgentID] | ||
213 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | ||
186 | } | 214 | } |
187 | 215 | ||
188 | public string GetCapsPath(UUID agentId) | 216 | public string GetCapsPath(UUID agentId) |
189 | { | 217 | { |
190 | if (capsPaths.ContainsKey(agentId)) | 218 | lock (m_capsPaths) |
191 | { | 219 | { |
192 | return capsPaths[agentId]; | 220 | if (m_capsPaths.ContainsKey(agentId)) |
221 | { | ||
222 | return m_capsPaths[agentId]; | ||
223 | } | ||
193 | } | 224 | } |
194 | 225 | ||
195 | return null; | 226 | return null; |
@@ -198,17 +229,24 @@ namespace OpenSim.Region.CoreModules.Framework | |||
198 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | 229 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) |
199 | { | 230 | { |
200 | Dictionary<ulong, string> seeds = null; | 231 | Dictionary<ulong, string> seeds = null; |
201 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 232 | |
202 | return seeds; | 233 | lock (m_childrenSeeds) |
234 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) | ||
235 | return seeds; | ||
236 | |||
203 | return new Dictionary<ulong, string>(); | 237 | return new Dictionary<ulong, string>(); |
204 | } | 238 | } |
205 | 239 | ||
206 | public void DropChildSeed(UUID agentID, ulong handle) | 240 | public void DropChildSeed(UUID agentID, ulong handle) |
207 | { | 241 | { |
208 | Dictionary<ulong, string> seeds; | 242 | Dictionary<ulong, string> seeds; |
209 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 243 | |
244 | lock (m_childrenSeeds) | ||
210 | { | 245 | { |
211 | seeds.Remove(handle); | 246 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) |
247 | { | ||
248 | seeds.Remove(handle); | ||
249 | } | ||
212 | } | 250 | } |
213 | } | 251 | } |
214 | 252 | ||
@@ -216,53 +254,285 @@ namespace OpenSim.Region.CoreModules.Framework | |||
216 | { | 254 | { |
217 | Dictionary<ulong, string> seeds; | 255 | Dictionary<ulong, string> seeds; |
218 | string returnval; | 256 | string returnval; |
219 | if (childrenSeeds.TryGetValue(agentID, out seeds)) | 257 | |
258 | lock (m_childrenSeeds) | ||
220 | { | 259 | { |
221 | if (seeds.TryGetValue(handle, out returnval)) | 260 | if (m_childrenSeeds.TryGetValue(agentID, out seeds)) |
222 | return returnval; | 261 | { |
262 | if (seeds.TryGetValue(handle, out returnval)) | ||
263 | return returnval; | ||
264 | } | ||
223 | } | 265 | } |
266 | |||
224 | return null; | 267 | return null; |
225 | } | 268 | } |
226 | 269 | ||
227 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) | 270 | public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) |
228 | { | 271 | { |
229 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); | 272 | //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); |
230 | childrenSeeds[agentID] = seeds; | 273 | |
274 | lock (m_childrenSeeds) | ||
275 | m_childrenSeeds[agentID] = seeds; | ||
231 | } | 276 | } |
232 | 277 | ||
233 | public void DumpChildrenSeeds(UUID agentID) | 278 | public void DumpChildrenSeeds(UUID agentID) |
234 | { | 279 | { |
235 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); | 280 | m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); |
236 | foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) | 281 | |
282 | lock (m_childrenSeeds) | ||
237 | { | 283 | { |
238 | uint x, y; | 284 | foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID]) |
239 | Utils.LongToUInts(kvp.Key, out x, out y); | 285 | { |
240 | x = x / Constants.RegionSize; | 286 | uint x, y; |
241 | y = y / Constants.RegionSize; | 287 | Utils.LongToUInts(kvp.Key, out x, out y); |
242 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | 288 | x = x / Constants.RegionSize; |
289 | y = y / Constants.RegionSize; | ||
290 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | ||
291 | } | ||
243 | } | 292 | } |
244 | } | 293 | } |
245 | 294 | ||
246 | private void HandleShowCapsCommand(string module, string[] cmdparams) | 295 | private void HandleShowCapsListCommand(string module, string[] cmdParams) |
247 | { | 296 | { |
297 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
298 | return; | ||
299 | |||
248 | StringBuilder caps = new StringBuilder(); | 300 | StringBuilder caps = new StringBuilder(); |
249 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 301 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); |
250 | 302 | ||
251 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) | 303 | lock (m_capsObjects) |
252 | { | 304 | { |
253 | caps.AppendFormat("** Circuit {0}:\n", kvp.Key); | 305 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) |
306 | { | ||
307 | caps.AppendFormat("** Circuit {0}:\n", kvp.Key); | ||
308 | |||
309 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | ||
310 | { | ||
311 | Uri uri = new Uri(kvp2.Value.ToString()); | ||
312 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | ||
313 | } | ||
314 | |||
315 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | ||
316 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
317 | } | ||
318 | } | ||
254 | 319 | ||
255 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 320 | MainConsole.Instance.Output(caps.ToString()); |
321 | } | ||
322 | |||
323 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) | ||
324 | { | ||
325 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
326 | return; | ||
327 | |||
328 | if (cmdParams.Length != 5 && cmdParams.Length != 6) | ||
329 | { | ||
330 | MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]"); | ||
331 | return; | ||
332 | } | ||
333 | |||
334 | StringBuilder sb = new StringBuilder(); | ||
335 | sb.AppendFormat("Region {0}:\n", m_scene.Name); | ||
336 | |||
337 | if (cmdParams.Length == 5) | ||
338 | { | ||
339 | BuildSummaryStatsByCapReport(sb); | ||
340 | } | ||
341 | else if (cmdParams.Length == 6) | ||
342 | { | ||
343 | BuildDetailedStatsByCapReport(sb, cmdParams[5]); | ||
344 | } | ||
345 | |||
346 | MainConsole.Instance.Output(sb.ToString()); | ||
347 | } | ||
348 | |||
349 | private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) | ||
350 | { | ||
351 | /* | ||
352 | sb.AppendFormat("Capability name {0}\n", capName); | ||
353 | |||
354 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
355 | cdt.AddColumn("User Name", 34); | ||
356 | cdt.AddColumn("Req Received", 12); | ||
357 | cdt.AddColumn("Req Handled", 12); | ||
358 | cdt.Indent = 2; | ||
359 | |||
360 | Dictionary<string, int> receivedStats = new Dictionary<string, int>(); | ||
361 | Dictionary<string, int> handledStats = new Dictionary<string, int>(); | ||
362 | |||
363 | m_scene.ForEachScenePresence( | ||
364 | sp => | ||
256 | { | 365 | { |
257 | Uri uri = new Uri(kvp2.Value.ToString()); | 366 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
258 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | 367 | |
368 | if (caps == null) | ||
369 | return; | ||
370 | |||
371 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
372 | |||
373 | IRequestHandler reqHandler; | ||
374 | if (capsHandlers.TryGetValue(capName, out reqHandler)) | ||
375 | { | ||
376 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | ||
377 | handledStats[sp.Name] = reqHandler.RequestsHandled; | ||
378 | } | ||
259 | } | 379 | } |
380 | ); | ||
260 | 381 | ||
261 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | 382 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) |
262 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | 383 | { |
384 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); | ||
263 | } | 385 | } |
264 | 386 | ||
265 | MainConsole.Instance.Output(caps.ToString()); | 387 | sb.Append(cdt.ToString()); |
388 | */ | ||
389 | } | ||
390 | |||
391 | private void BuildSummaryStatsByCapReport(StringBuilder sb) | ||
392 | { | ||
393 | /* | ||
394 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
395 | cdt.AddColumn("Name", 34); | ||
396 | cdt.AddColumn("Req Received", 12); | ||
397 | cdt.AddColumn("Req Handled", 12); | ||
398 | cdt.Indent = 2; | ||
399 | |||
400 | Dictionary<string, int> receivedStats = new Dictionary<string, int>(); | ||
401 | Dictionary<string, int> handledStats = new Dictionary<string, int>(); | ||
402 | |||
403 | m_scene.ForEachScenePresence( | ||
404 | sp => | ||
405 | { | ||
406 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
407 | |||
408 | if (caps == null) | ||
409 | return; | ||
410 | |||
411 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
412 | |||
413 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | ||
414 | { | ||
415 | string reqName = reqHandler.Name ?? ""; | ||
416 | |||
417 | if (!receivedStats.ContainsKey(reqName)) | ||
418 | { | ||
419 | receivedStats[reqName] = reqHandler.RequestsReceived; | ||
420 | handledStats[reqName] = reqHandler.RequestsHandled; | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | receivedStats[reqName] += reqHandler.RequestsReceived; | ||
425 | handledStats[reqName] += reqHandler.RequestsHandled; | ||
426 | } | ||
427 | } | ||
428 | } | ||
429 | ); | ||
430 | |||
431 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) | ||
432 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); | ||
433 | |||
434 | sb.Append(cdt.ToString()); | ||
435 | */ | ||
436 | } | ||
437 | |||
438 | private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) | ||
439 | { | ||
440 | /* | ||
441 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | ||
442 | return; | ||
443 | |||
444 | if (cmdParams.Length != 5 && cmdParams.Length != 7) | ||
445 | { | ||
446 | MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]"); | ||
447 | return; | ||
448 | } | ||
449 | |||
450 | StringBuilder sb = new StringBuilder(); | ||
451 | sb.AppendFormat("Region {0}:\n", m_scene.Name); | ||
452 | |||
453 | if (cmdParams.Length == 5) | ||
454 | { | ||
455 | BuildSummaryStatsByUserReport(sb); | ||
456 | } | ||
457 | else if (cmdParams.Length == 7) | ||
458 | { | ||
459 | string firstName = cmdParams[5]; | ||
460 | string lastName = cmdParams[6]; | ||
461 | |||
462 | ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); | ||
463 | |||
464 | if (sp == null) | ||
465 | return; | ||
466 | |||
467 | BuildDetailedStatsByUserReport(sb, sp); | ||
468 | } | ||
469 | |||
470 | MainConsole.Instance.Output(sb.ToString()); | ||
471 | */ | ||
472 | } | ||
473 | |||
474 | private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) | ||
475 | { | ||
476 | /* | ||
477 | sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); | ||
478 | |||
479 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
480 | cdt.AddColumn("Cap Name", 34); | ||
481 | cdt.AddColumn("Req Received", 12); | ||
482 | cdt.AddColumn("Req Handled", 12); | ||
483 | cdt.Indent = 2; | ||
484 | |||
485 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
486 | |||
487 | if (caps == null) | ||
488 | return; | ||
489 | |||
490 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
491 | |||
492 | foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived)) | ||
493 | { | ||
494 | cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled); | ||
495 | } | ||
496 | |||
497 | sb.Append(cdt.ToString()); | ||
498 | */ | ||
499 | } | ||
500 | |||
501 | private void BuildSummaryStatsByUserReport(StringBuilder sb) | ||
502 | { | ||
503 | /* | ||
504 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | ||
505 | cdt.AddColumn("Name", 32); | ||
506 | cdt.AddColumn("Type", 5); | ||
507 | cdt.AddColumn("Req Received", 12); | ||
508 | cdt.AddColumn("Req Handled", 12); | ||
509 | cdt.Indent = 2; | ||
510 | |||
511 | m_scene.ForEachScenePresence( | ||
512 | sp => | ||
513 | { | ||
514 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | ||
515 | |||
516 | if (caps == null) | ||
517 | return; | ||
518 | |||
519 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
520 | |||
521 | int totalRequestsReceived = 0; | ||
522 | int totalRequestsHandled = 0; | ||
523 | |||
524 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | ||
525 | { | ||
526 | totalRequestsReceived += reqHandler.RequestsReceived; | ||
527 | totalRequestsHandled += reqHandler.RequestsHandled; | ||
528 | } | ||
529 | |||
530 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | ||
531 | } | ||
532 | ); | ||
533 | |||
534 | sb.Append(cdt.ToString()); | ||
535 | */ | ||
266 | } | 536 | } |
267 | } | 537 | } |
268 | } | 538 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index b9c88d4..a3c539d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -822,7 +822,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
822 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", | 822 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", |
823 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); | 823 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); |
824 | 824 | ||
825 | Fail(sp, finalDestination, logout, "Connection between viewer and destination region could not be established."); | 825 | Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); |
826 | return; | 826 | return; |
827 | } | 827 | } |
828 | 828 | ||
@@ -834,7 +834,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
834 | "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", | 834 | "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", |
835 | sp.Name, finalDestination.RegionName, sp.Scene.Name); | 835 | sp.Name, finalDestination.RegionName, sp.Scene.Name); |
836 | 836 | ||
837 | CleanupFailedInterRegionTeleport(sp, finalDestination); | 837 | CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination); |
838 | 838 | ||
839 | return; | 839 | return; |
840 | } | 840 | } |
@@ -878,7 +878,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
878 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", | 878 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", |
879 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); | 879 | sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); |
880 | 880 | ||
881 | Fail(sp, finalDestination, logout, "Destination region did not signal teleport completion."); | 881 | Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion."); |
882 | 882 | ||
883 | return; | 883 | return; |
884 | } | 884 | } |
@@ -932,7 +932,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
932 | /// <remarks> | 932 | /// <remarks> |
933 | /// <param name='sp'> </param> | 933 | /// <param name='sp'> </param> |
934 | /// <param name='finalDestination'></param> | 934 | /// <param name='finalDestination'></param> |
935 | protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, GridRegion finalDestination) | 935 | protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, string auth_token, GridRegion finalDestination) |
936 | { | 936 | { |
937 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); | 937 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); |
938 | 938 | ||
@@ -943,7 +943,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
943 | 943 | ||
944 | // Finally, kill the agent we just created at the destination. | 944 | // Finally, kill the agent we just created at the destination. |
945 | // XXX: Possibly this should be done asynchronously. | 945 | // XXX: Possibly this should be done asynchronously. |
946 | Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); | 946 | Scene.SimulationService.CloseAgent(finalDestination, sp.UUID, auth_token); |
947 | } | 947 | } |
948 | 948 | ||
949 | /// <summary> | 949 | /// <summary> |
@@ -953,9 +953,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
953 | /// <param name='finalDestination'></param> | 953 | /// <param name='finalDestination'></param> |
954 | /// <param name='logout'></param> | 954 | /// <param name='logout'></param> |
955 | /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param> | 955 | /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param> |
956 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string reason) | 956 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string auth_code, string reason) |
957 | { | 957 | { |
958 | CleanupFailedInterRegionTeleport(sp, finalDestination); | 958 | CleanupFailedInterRegionTeleport(sp, auth_code, finalDestination); |
959 | 959 | ||
960 | m_interRegionTeleportFailures.Value++; | 960 | m_interRegionTeleportFailures.Value++; |
961 | 961 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 73b3678f..1cf1884 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -171,11 +171,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
171 | if (!so.IsAttachment) | 171 | if (!so.IsAttachment) |
172 | return; | 172 | return; |
173 | 173 | ||
174 | if (so.Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar)) | 174 | if (so.AttachedAvatar == UUID.Zero || Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar)) |
175 | return; | 175 | return; |
176 | 176 | ||
177 | // foreign user | 177 | // foreign user |
178 | AgentCircuitData aCircuit = so.Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar); | 178 | AgentCircuitData aCircuit = Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar); |
179 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | 179 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
180 | { | 180 | { |
181 | if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | 181 | if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) |
@@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); |
184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); | 184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); |
185 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 185 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); |
186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(so.Scene.AssetService, url); | 186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); |
187 | uuidGatherer.GatherAssetUuids(so, ids); | 187 | uuidGatherer.GatherAssetUuids(so, ids); |
188 | 188 | ||
189 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) | 189 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) |
@@ -207,6 +207,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
207 | { | 207 | { |
208 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); | 208 | m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); |
209 | m_UAS = scene.RequestModuleInterface<IUserAgentService>(); | 209 | m_UAS = scene.RequestModuleInterface<IUserAgentService>(); |
210 | if (m_UAS == null) | ||
211 | m_UAS = new UserAgentServiceConnector(m_ThisHomeURI); | ||
212 | |||
210 | } | 213 | } |
211 | } | 214 | } |
212 | 215 | ||
@@ -571,12 +574,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
571 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) | 574 | if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) |
572 | { | 575 | { |
573 | // local grid user | 576 | // local grid user |
577 | m_UAS.LogoutAgent(obj.AgentId, obj.SessionId); | ||
574 | return; | 578 | return; |
575 | } | 579 | } |
576 | 580 | ||
577 | AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); | 581 | AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); |
578 | 582 | if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("HomeURI")) | |
579 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | ||
580 | { | 583 | { |
581 | string url = aCircuit.ServiceURLs["HomeURI"].ToString(); | 584 | string url = aCircuit.ServiceURLs["HomeURI"].ToString(); |
582 | IUserAgentService security = new UserAgentServiceConnector(url); | 585 | IUserAgentService security = new UserAgentServiceConnector(url); |
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs new file mode 100644 index 0000000..f1eb1ad --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Framework.Monitoring; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.Framework | ||
43 | { | ||
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridServiceThrottleModule")] | ||
45 | public class GridServiceThrottleModule : ISharedRegionModule | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger( | ||
48 | MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private readonly List<Scene> m_scenes = new List<Scene>(); | ||
51 | |||
52 | private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); | ||
53 | |||
54 | public void Initialise(IConfigSource config) | ||
55 | { | ||
56 | Watchdog.StartThread( | ||
57 | ProcessQueue, | ||
58 | "GridServiceRequestThread", | ||
59 | ThreadPriority.BelowNormal, | ||
60 | true, | ||
61 | false); | ||
62 | } | ||
63 | |||
64 | public void AddRegion(Scene scene) | ||
65 | { | ||
66 | lock (m_scenes) | ||
67 | { | ||
68 | m_scenes.Add(scene); | ||
69 | scene.EventManager.OnNewClient += OnNewClient; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | public void RegionLoaded(Scene scene) | ||
74 | { | ||
75 | } | ||
76 | |||
77 | public void RemoveRegion(Scene scene) | ||
78 | { | ||
79 | lock (m_scenes) | ||
80 | { | ||
81 | m_scenes.Remove(scene); | ||
82 | scene.EventManager.OnNewClient -= OnNewClient; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | void OnNewClient(IClientAPI client) | ||
87 | { | ||
88 | client.OnRegionHandleRequest += OnRegionHandleRequest; | ||
89 | } | ||
90 | |||
91 | public void PostInitialise() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public void Close() | ||
96 | { | ||
97 | } | ||
98 | |||
99 | public string Name | ||
100 | { | ||
101 | get { return "GridServiceThrottleModule"; } | ||
102 | } | ||
103 | |||
104 | public Type ReplaceableInterface | ||
105 | { | ||
106 | get { return null; } | ||
107 | } | ||
108 | |||
109 | public void OnRegionHandleRequest(IClientAPI client, UUID regionID) | ||
110 | { | ||
111 | //m_log.DebugFormat("[GRIDSERVICE THROTTLE]: RegionHandleRequest {0}", regionID); | ||
112 | ulong handle = 0; | ||
113 | if (IsLocalRegionHandle(regionID, out handle)) | ||
114 | { | ||
115 | client.SendRegionHandle(regionID, handle); | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | GridRegionRequest request = new GridRegionRequest(client, regionID); | ||
120 | m_RequestQueue.Enqueue(request); | ||
121 | |||
122 | } | ||
123 | |||
124 | private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle) | ||
125 | { | ||
126 | regionHandle = 0; | ||
127 | foreach (Scene s in m_scenes) | ||
128 | if (s.RegionInfo.RegionID == regionID) | ||
129 | { | ||
130 | regionHandle = s.RegionInfo.RegionHandle; | ||
131 | return true; | ||
132 | } | ||
133 | return false; | ||
134 | } | ||
135 | |||
136 | private void ProcessQueue() | ||
137 | { | ||
138 | while (true) | ||
139 | { | ||
140 | Watchdog.UpdateThread(); | ||
141 | |||
142 | GridRegionRequest request = m_RequestQueue.Dequeue(); | ||
143 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID); | ||
144 | |||
145 | if (r != null && r.RegionHandle != 0) | ||
146 | request.client.SendRegionHandle(request.regionID, r.RegionHandle); | ||
147 | |||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
152 | class GridRegionRequest | ||
153 | { | ||
154 | public IClientAPI client; | ||
155 | public UUID regionID; | ||
156 | |||
157 | public GridRegionRequest(IClientAPI c, UUID r) | ||
158 | { | ||
159 | client = c; | ||
160 | regionID = r; | ||
161 | } | ||
162 | } | ||
163 | } | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 1eae0ac..e0c8ea6 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -135,7 +135,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
135 | if (sp is ScenePresence) | 135 | if (sp is ScenePresence) |
136 | { | 136 | { |
137 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); | 137 | AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); |
138 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | 138 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) |
139 | { | 139 | { |
140 | if (m_RestrictInventoryAccessAbroad) | 140 | if (m_RestrictInventoryAccessAbroad) |
141 | { | 141 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index d07cff4..69d7e16 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
176 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); | 176 | m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); |
177 | simpleName = GetInventoryPathFromName(simpleName); | 177 | simpleName = GetInventoryPathFromName(simpleName); |
178 | 178 | ||
179 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName, false); | 179 | InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, simpleName, iarFileName, false); |
180 | try | 180 | try |
181 | { | 181 | { |
182 | HashSet<InventoryNodeBase> nodes = archread.Execute(); | 182 | HashSet<InventoryNodeBase> nodes = archread.Execute(); |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
185 | // didn't find the subfolder with the given name; place it on the top | 185 | // didn't find the subfolder with the given name; place it on the top |
186 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); | 186 | m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); |
187 | archread.Close(); | 187 | archread.Close(); |
188 | archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); | 188 | archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, "/", iarFileName, false); |
189 | archread.Execute(); | 189 | archread.Execute(); |
190 | } | 190 | } |
191 | 191 | ||
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 | |||
58 | if (umanmod == Name) | 58 | if (umanmod == Name) |
59 | { | 59 | { |
60 | m_Enabled = true; | 60 | m_Enabled = true; |
61 | RegisterConsoleCmds(); | 61 | Init(); |
62 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); | 62 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); |
63 | } | 63 | } |
64 | } | 64 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index a7cbc8f..a528093 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -28,9 +28,11 @@ using System; | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Threading; | ||
31 | 32 | ||
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Monitoring; | ||
34 | using OpenSim.Region.ClientStack.LindenUDP; | 36 | using OpenSim.Region.ClientStack.LindenUDP; |
35 | using OpenSim.Region.Framework; | 37 | using OpenSim.Region.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
@@ -57,6 +59,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
57 | // The cache | 59 | // The cache |
58 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); | 60 | protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); |
59 | 61 | ||
62 | // Throttle the name requests | ||
63 | private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>(); | ||
64 | |||
65 | |||
60 | #region ISharedRegionModule | 66 | #region ISharedRegionModule |
61 | 67 | ||
62 | public void Initialise(IConfigSource config) | 68 | public void Initialise(IConfigSource config) |
@@ -65,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
65 | if (umanmod == Name) | 71 | if (umanmod == Name) |
66 | { | 72 | { |
67 | m_Enabled = true; | 73 | m_Enabled = true; |
68 | RegisterConsoleCmds(); | 74 | Init(); |
69 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); | 75 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); |
70 | } | 76 | } |
71 | } | 77 | } |
@@ -160,16 +166,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
160 | } | 166 | } |
161 | else | 167 | else |
162 | { | 168 | { |
163 | string[] names; | 169 | NameRequest request = new NameRequest(remote_client, uuid); |
164 | bool foundRealName = TryGetUserNames(uuid, out names); | 170 | m_RequestQueue.Enqueue(request); |
165 | 171 | ||
166 | if (names.Length == 2) | ||
167 | { | ||
168 | if (!foundRealName) | ||
169 | 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); | ||
170 | |||
171 | remote_client.SendNameReply(uuid, names[0], names[1]); | ||
172 | } | ||
173 | } | 172 | } |
174 | } | 173 | } |
175 | 174 | ||
@@ -514,9 +513,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
514 | return; | 513 | return; |
515 | } | 514 | } |
516 | 515 | ||
517 | //try update unknown users | 516 | //try update unknown users, but don't update anyone else |
518 | //and creator's home URL's | 517 | if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) |
519 | if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL))) | ||
520 | { | 518 | { |
521 | lock (m_UserCache) | 519 | lock (m_UserCache) |
522 | m_UserCache.Remove(id); | 520 | m_UserCache.Remove(id); |
@@ -597,6 +595,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
597 | 595 | ||
598 | #endregion IUserManagement | 596 | #endregion IUserManagement |
599 | 597 | ||
598 | protected void Init() | ||
599 | { | ||
600 | RegisterConsoleCmds(); | ||
601 | Watchdog.StartThread( | ||
602 | ProcessQueue, | ||
603 | "NameRequestThread", | ||
604 | ThreadPriority.BelowNormal, | ||
605 | true, | ||
606 | false); | ||
607 | |||
608 | } | ||
609 | |||
600 | protected void RegisterConsoleCmds() | 610 | protected void RegisterConsoleCmds() |
601 | { | 611 | { |
602 | MainConsole.Instance.Commands.AddCommand("Users", true, | 612 | MainConsole.Instance.Commands.AddCommand("Users", true, |
@@ -663,5 +673,40 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
663 | 673 | ||
664 | MainConsole.Instance.Output(cdt.ToString()); | 674 | MainConsole.Instance.Output(cdt.ToString()); |
665 | } | 675 | } |
676 | |||
677 | private void ProcessQueue() | ||
678 | { | ||
679 | while (true) | ||
680 | { | ||
681 | Watchdog.UpdateThread(); | ||
682 | |||
683 | NameRequest request = m_RequestQueue.Dequeue(); | ||
684 | string[] names; | ||
685 | bool foundRealName = TryGetUserNames(request.uuid, out names); | ||
686 | |||
687 | if (names.Length == 2) | ||
688 | { | ||
689 | if (!foundRealName) | ||
690 | 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); | ||
691 | |||
692 | request.client.SendNameReply(request.uuid, names[0], names[1]); | ||
693 | } | ||
694 | |||
695 | } | ||
696 | } | ||
697 | |||
698 | } | ||
699 | |||
700 | class NameRequest | ||
701 | { | ||
702 | public IClientAPI client; | ||
703 | public UUID uuid; | ||
704 | |||
705 | public NameRequest(IClientAPI c, UUID n) | ||
706 | { | ||
707 | client = c; | ||
708 | uuid = n; | ||
709 | } | ||
666 | } | 710 | } |
711 | |||
667 | } \ No newline at end of file | 712 | } \ No newline at end of file |