diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs (renamed from OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs) | 169 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 122 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 6 |
5 files changed, 270 insertions, 125 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index a60b314..505bb53 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -75,10 +75,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
75 | public void AddRegion(Scene scene) | 75 | public void AddRegion(Scene scene) |
76 | { | 76 | { |
77 | m_scene = scene; | 77 | m_scene = scene; |
78 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | ||
79 | |||
80 | if (Enabled) | 78 | if (Enabled) |
81 | { | 79 | { |
80 | // Only register module with scene if it is enabled. All callers check for a null attachments module. | ||
81 | // Ideally, there should be a null attachments module for when this core attachments module has been | ||
82 | // disabled. Registering only when enabled allows for other attachments module implementations. | ||
83 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | ||
82 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 84 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
83 | m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); | 85 | m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); |
84 | m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); | 86 | m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); |
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 6ce6227..0c759df 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
80 | 80 | ||
81 | MainConsole.Instance.Commands.AddCommand( | 81 | MainConsole.Instance.Commands.AddCommand( |
82 | "Comms", false, "show caps stats by user", | 82 | "Comms", false, "show caps stats by user", |
83 | "show caps stats [<first-name> <last-name>]", | 83 | "show caps stats by user [<first-name> <last-name>]", |
84 | "Shows statistics on capabilities use by user.", | 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.", | 85 | "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.", |
86 | HandleShowCapsStatsByUserCommand); | 86 | HandleShowCapsStatsByUserCommand); |
@@ -296,27 +296,31 @@ namespace OpenSim.Region.CoreModules.Framework | |||
296 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | 296 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
297 | return; | 297 | return; |
298 | 298 | ||
299 | StringBuilder caps = new StringBuilder(); | 299 | StringBuilder capsReport = new StringBuilder(); |
300 | caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); | 300 | capsReport.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); |
301 | 301 | ||
302 | lock (m_capsObjects) | 302 | lock (m_capsObjects) |
303 | { | 303 | { |
304 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) | 304 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) |
305 | { | 305 | { |
306 | caps.AppendFormat("** Circuit {0}:\n", kvp.Key); | 306 | capsReport.AppendFormat("** Circuit {0}:\n", kvp.Key); |
307 | Caps caps = kvp.Value; | ||
307 | 308 | ||
308 | for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 309 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) |
309 | { | 310 | { |
310 | Uri uri = new Uri(kvp2.Value.ToString()); | 311 | Uri uri = new Uri(kvp2.Value.ToString()); |
311 | caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); | 312 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); |
312 | } | 313 | } |
313 | 314 | ||
314 | foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) | 315 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp2 in caps.GetPollHandlers()) |
315 | caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | 316 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp2.Key, kvp2.Value.Url); |
317 | |||
318 | foreach (KeyValuePair<string, string> kvp3 in caps.ExternalCapsHandlers) | ||
319 | capsReport.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); | ||
316 | } | 320 | } |
317 | } | 321 | } |
318 | 322 | ||
319 | MainConsole.Instance.Output(caps.ToString()); | 323 | MainConsole.Instance.Output(capsReport.ToString()); |
320 | } | 324 | } |
321 | 325 | ||
322 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) | 326 | private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams) |
@@ -374,7 +378,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
374 | { | 378 | { |
375 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | 379 | receivedStats[sp.Name] = reqHandler.RequestsReceived; |
376 | handledStats[sp.Name] = reqHandler.RequestsHandled; | 380 | handledStats[sp.Name] = reqHandler.RequestsHandled; |
377 | } | 381 | } |
382 | else | ||
383 | { | ||
384 | PollServiceEventArgs pollHandler = null; | ||
385 | if (caps.TryGetPollHandler(capName, out pollHandler)) | ||
386 | { | ||
387 | receivedStats[sp.Name] = pollHandler.RequestsReceived; | ||
388 | handledStats[sp.Name] = pollHandler.RequestsHandled; | ||
389 | } | ||
390 | } | ||
378 | } | 391 | } |
379 | ); | 392 | ); |
380 | 393 | ||
@@ -405,11 +418,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
405 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | 418 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
406 | 419 | ||
407 | if (caps == null) | 420 | if (caps == null) |
408 | return; | 421 | return; |
409 | |||
410 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | ||
411 | 422 | ||
412 | foreach (IRequestHandler reqHandler in capsHandlers.Values) | 423 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
413 | { | 424 | { |
414 | string reqName = reqHandler.Name ?? ""; | 425 | string reqName = reqHandler.Name ?? ""; |
415 | 426 | ||
@@ -424,6 +435,23 @@ namespace OpenSim.Region.CoreModules.Framework | |||
424 | handledStats[reqName] += reqHandler.RequestsHandled; | 435 | handledStats[reqName] += reqHandler.RequestsHandled; |
425 | } | 436 | } |
426 | } | 437 | } |
438 | |||
439 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) | ||
440 | { | ||
441 | string name = kvp.Key; | ||
442 | PollServiceEventArgs pollHandler = kvp.Value; | ||
443 | |||
444 | if (!receivedStats.ContainsKey(name)) | ||
445 | { | ||
446 | receivedStats[name] = pollHandler.RequestsReceived; | ||
447 | handledStats[name] = pollHandler.RequestsHandled; | ||
448 | } | ||
449 | else | ||
450 | { | ||
451 | receivedStats[name] += pollHandler.RequestsReceived; | ||
452 | handledStats[name] += pollHandler.RequestsHandled; | ||
453 | } | ||
454 | } | ||
427 | } | 455 | } |
428 | ); | 456 | ); |
429 | 457 | ||
@@ -486,12 +514,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
486 | if (caps == null) | 514 | if (caps == null) |
487 | return; | 515 | return; |
488 | 516 | ||
489 | Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers(); | 517 | List<CapTableRow> capRows = new List<CapTableRow>(); |
490 | 518 | ||
491 | foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived)) | 519 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
492 | { | 520 | capRows.Add(new CapTableRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled)); |
493 | cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled); | 521 | |
494 | } | 522 | foreach (KeyValuePair<string, PollServiceEventArgs> kvp in caps.GetPollHandlers()) |
523 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); | ||
524 | |||
525 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) | ||
526 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); | ||
495 | 527 | ||
496 | sb.Append(cdt.ToString()); | 528 | sb.Append(cdt.ToString()); |
497 | */ | 529 | */ |
@@ -525,6 +557,14 @@ namespace OpenSim.Region.CoreModules.Framework | |||
525 | totalRequestsReceived += reqHandler.RequestsReceived; | 557 | totalRequestsReceived += reqHandler.RequestsReceived; |
526 | totalRequestsHandled += reqHandler.RequestsHandled; | 558 | totalRequestsHandled += reqHandler.RequestsHandled; |
527 | } | 559 | } |
560 | |||
561 | Dictionary<string, PollServiceEventArgs> capsPollHandlers = caps.GetPollHandlers(); | ||
562 | |||
563 | foreach (PollServiceEventArgs handler in capsPollHandlers.Values) | ||
564 | { | ||
565 | totalRequestsReceived += handler.RequestsReceived; | ||
566 | totalRequestsHandled += handler.RequestsHandled; | ||
567 | } | ||
528 | 568 | ||
529 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | 569 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); |
530 | } | 570 | } |
@@ -533,5 +573,19 @@ namespace OpenSim.Region.CoreModules.Framework | |||
533 | sb.Append(cdt.ToString()); | 573 | sb.Append(cdt.ToString()); |
534 | */ | 574 | */ |
535 | } | 575 | } |
576 | |||
577 | private class CapTableRow | ||
578 | { | ||
579 | public string Name { get; set; } | ||
580 | public int RequestsReceived { get; set; } | ||
581 | public int RequestsHandled { get; set; } | ||
582 | |||
583 | public CapTableRow(string name, int requestsReceived, int requestsHandled) | ||
584 | { | ||
585 | Name = name; | ||
586 | RequestsReceived = requestsReceived; | ||
587 | RequestsHandled = requestsHandled; | ||
588 | } | ||
589 | } | ||
536 | } | 590 | } |
537 | } | 591 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs index f1eb1ad..a70261e 100644 --- a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs | |||
@@ -42,23 +42,37 @@ 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); |
49 | 49 | ||
50 | private readonly List<Scene> m_scenes = new List<Scene>(); | 50 | private readonly List<Scene> m_scenes = new List<Scene>(); |
51 | private System.Timers.Timer m_timer = new System.Timers.Timer(); | ||
51 | 52 | ||
52 | private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); | 53 | private Queue<Action> m_RequestQueue = new Queue<Action>(); |
54 | private Dictionary<string, List<string>> m_Pending = new Dictionary<string, List<string>>(); | ||
55 | private int m_Interval; | ||
56 | |||
57 | #region ISharedRegionModule | ||
53 | 58 | ||
54 | public void Initialise(IConfigSource config) | 59 | public void Initialise(IConfigSource config) |
55 | { | 60 | { |
56 | Watchdog.StartThread( | 61 | m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 5000); |
57 | ProcessQueue, | 62 | |
58 | "GridServiceRequestThread", | 63 | m_timer = new System.Timers.Timer(); |
59 | ThreadPriority.BelowNormal, | 64 | m_timer.AutoReset = false; |
60 | true, | 65 | m_timer.Enabled = true; |
61 | false); | 66 | m_timer.Interval = 15000; // 15 secs at first |
67 | m_timer.Elapsed += ProcessQueue; | ||
68 | m_timer.Start(); | ||
69 | |||
70 | //Watchdog.StartThread( | ||
71 | // ProcessQueue, | ||
72 | // "GridServiceRequestThread", | ||
73 | // ThreadPriority.BelowNormal, | ||
74 | // true, | ||
75 | // false); | ||
62 | } | 76 | } |
63 | 77 | ||
64 | public void AddRegion(Scene scene) | 78 | public void AddRegion(Scene scene) |
@@ -66,7 +80,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
66 | lock (m_scenes) | 80 | lock (m_scenes) |
67 | { | 81 | { |
68 | m_scenes.Add(scene); | 82 | m_scenes.Add(scene); |
83 | scene.RegisterModuleInterface<IServiceThrottleModule>(this); | ||
69 | scene.EventManager.OnNewClient += OnNewClient; | 84 | scene.EventManager.OnNewClient += OnNewClient; |
85 | scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; | ||
70 | } | 86 | } |
71 | } | 87 | } |
72 | 88 | ||
@@ -83,11 +99,6 @@ namespace OpenSim.Region.CoreModules.Framework | |||
83 | } | 99 | } |
84 | } | 100 | } |
85 | 101 | ||
86 | void OnNewClient(IClientAPI client) | ||
87 | { | ||
88 | client.OnRegionHandleRequest += OnRegionHandleRequest; | ||
89 | } | ||
90 | |||
91 | public void PostInitialise() | 102 | public void PostInitialise() |
92 | { | 103 | { |
93 | } | 104 | } |
@@ -98,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
98 | 109 | ||
99 | public string Name | 110 | public string Name |
100 | { | 111 | { |
101 | get { return "GridServiceThrottleModule"; } | 112 | get { return "ServiceThrottleModule"; } |
102 | } | 113 | } |
103 | 114 | ||
104 | public Type ReplaceableInterface | 115 | public Type ReplaceableInterface |
@@ -106,9 +117,31 @@ namespace OpenSim.Region.CoreModules.Framework | |||
106 | get { return null; } | 117 | get { return null; } |
107 | } | 118 | } |
108 | 119 | ||
120 | #endregion ISharedRegionMOdule | ||
121 | |||
122 | #region Events | ||
123 | |||
124 | void OnNewClient(IClientAPI client) | ||
125 | { | ||
126 | client.OnRegionHandleRequest += OnRegionHandleRequest; | ||
127 | } | ||
128 | |||
129 | void OnMakeRootAgent(ScenePresence obj) | ||
130 | { | ||
131 | lock (m_timer) | ||
132 | { | ||
133 | if (!m_timer.Enabled) | ||
134 | { | ||
135 | m_timer.Interval = m_Interval; | ||
136 | m_timer.Enabled = true; | ||
137 | m_timer.Start(); | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
109 | public void OnRegionHandleRequest(IClientAPI client, UUID regionID) | 142 | public void OnRegionHandleRequest(IClientAPI client, UUID regionID) |
110 | { | 143 | { |
111 | //m_log.DebugFormat("[GRIDSERVICE THROTTLE]: RegionHandleRequest {0}", regionID); | 144 | //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID); |
112 | ulong handle = 0; | 145 | ulong handle = 0; |
113 | if (IsLocalRegionHandle(regionID, out handle)) | 146 | if (IsLocalRegionHandle(regionID, out handle)) |
114 | { | 147 | { |
@@ -116,11 +149,83 @@ namespace OpenSim.Region.CoreModules.Framework | |||
116 | return; | 149 | return; |
117 | } | 150 | } |
118 | 151 | ||
119 | GridRegionRequest request = new GridRegionRequest(client, regionID); | 152 | Action action = delegate |
120 | m_RequestQueue.Enqueue(request); | 153 | { |
154 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID); | ||
155 | |||
156 | if (r != null && r.RegionHandle != 0) | ||
157 | client.SendRegionHandle(regionID, r.RegionHandle); | ||
158 | }; | ||
159 | |||
160 | Enqueue("region", regionID.ToString(), action); | ||
161 | } | ||
162 | |||
163 | #endregion Events | ||
164 | |||
165 | #region IServiceThrottleModule | ||
166 | |||
167 | public void Enqueue(string category, string itemid, Action continuation) | ||
168 | { | ||
169 | lock (m_RequestQueue) | ||
170 | { | ||
171 | if (m_Pending.ContainsKey(category)) | ||
172 | { | ||
173 | if (m_Pending[category].Contains(itemid)) | ||
174 | // Don't enqueue, it's already pending | ||
175 | return; | ||
176 | } | ||
177 | else | ||
178 | m_Pending.Add(category, new List<string>()); | ||
179 | |||
180 | m_Pending[category].Add(itemid); | ||
181 | |||
182 | m_RequestQueue.Enqueue(delegate | ||
183 | { | ||
184 | lock (m_RequestQueue) | ||
185 | m_Pending[category].Remove(itemid); | ||
186 | |||
187 | continuation(); | ||
188 | }); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | #endregion IServiceThrottleModule | ||
193 | |||
194 | #region Process Continuation Queue | ||
195 | |||
196 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) | ||
197 | { | ||
198 | //m_log.DebugFormat("[YYY]: Process queue with {0} continuations", m_RequestQueue.Count); | ||
199 | |||
200 | while (m_RequestQueue.Count > 0) | ||
201 | { | ||
202 | Action continuation = null; | ||
203 | lock (m_RequestQueue) | ||
204 | continuation = m_RequestQueue.Dequeue(); | ||
205 | |||
206 | if (continuation != null) | ||
207 | continuation(); | ||
208 | } | ||
209 | |||
210 | if (AreThereRootAgents()) | ||
211 | { | ||
212 | lock (m_timer) | ||
213 | { | ||
214 | m_timer.Interval = 1000; // 1 sec | ||
215 | m_timer.Enabled = true; | ||
216 | m_timer.Start(); | ||
217 | } | ||
218 | } | ||
219 | else | ||
220 | lock (m_timer) | ||
221 | m_timer.Enabled = false; | ||
121 | 222 | ||
122 | } | 223 | } |
123 | 224 | ||
225 | #endregion Process Continuation Queue | ||
226 | |||
227 | #region Misc | ||
228 | |||
124 | private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle) | 229 | private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle) |
125 | { | 230 | { |
126 | regionHandle = 0; | 231 | regionHandle = 0; |
@@ -133,31 +238,19 @@ namespace OpenSim.Region.CoreModules.Framework | |||
133 | return false; | 238 | return false; |
134 | } | 239 | } |
135 | 240 | ||
136 | private void ProcessQueue() | 241 | private bool AreThereRootAgents() |
137 | { | 242 | { |
138 | while (true) | 243 | foreach (Scene s in m_scenes) |
139 | { | 244 | { |
140 | Watchdog.UpdateThread(); | 245 | foreach (ScenePresence sp in s.GetScenePresences()) |
141 | 246 | if (!sp.IsChildAgent) | |
142 | GridRegionRequest request = m_RequestQueue.Dequeue(); | 247 | return true; |
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 | } | 248 | } |
149 | } | ||
150 | } | ||
151 | |||
152 | class GridRegionRequest | ||
153 | { | ||
154 | public IClientAPI client; | ||
155 | public UUID regionID; | ||
156 | 249 | ||
157 | public GridRegionRequest(IClientAPI c, UUID r) | 250 | return false; |
158 | { | ||
159 | client = c; | ||
160 | regionID = r; | ||
161 | } | 251 | } |
252 | |||
253 | #endregion Misc | ||
162 | } | 254 | } |
255 | |||
163 | } | 256 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index a528093..a91adfa 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -56,13 +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 | |||
65 | |||
66 | #region ISharedRegionModule | 63 | #region ISharedRegionModule |
67 | 64 | ||
68 | public void Initialise(IConfigSource config) | 65 | public void Initialise(IConfigSource config) |
@@ -115,6 +112,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
115 | 112 | ||
116 | public void RegionLoaded(Scene s) | 113 | public void RegionLoaded(Scene s) |
117 | { | 114 | { |
115 | if (m_Enabled && m_ServiceThrottle == null) | ||
116 | m_ServiceThrottle = s.RequestModuleInterface<IServiceThrottleModule>(); | ||
118 | } | 117 | } |
119 | 118 | ||
120 | public void PostInitialise() | 119 | public void PostInitialise() |
@@ -154,7 +153,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
154 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); | 153 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); |
155 | } | 154 | } |
156 | 155 | ||
157 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | 156 | void HandleUUIDNameRequest(UUID uuid, IClientAPI client) |
158 | { | 157 | { |
159 | // m_log.DebugFormat( | 158 | // m_log.DebugFormat( |
160 | // "[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}", |
@@ -162,12 +161,31 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
162 | 161 | ||
163 | 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)) |
164 | { | 163 | { |
165 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | 164 | client.SendNameReply(uuid, "Mr", "OpenSim"); |
166 | } | 165 | } |
167 | else | 166 | else |
168 | { | 167 | { |
169 | NameRequest request = new NameRequest(remote_client, uuid); | 168 | string[] names = new string[2]; |
170 | 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, queue continuation | ||
176 | m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate | ||
177 | { | ||
178 | //m_log.DebugFormat("[YYY]: Name request {0}", uuid); | ||
179 | bool foundRealName = TryGetUserNames(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 | |||
186 | client.SendNameReply(uuid, names[0], names[1]); | ||
187 | } | ||
188 | }); | ||
171 | 189 | ||
172 | } | 190 | } |
173 | } | 191 | } |
@@ -283,15 +301,27 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
283 | } | 301 | } |
284 | 302 | ||
285 | /// <summary> | 303 | /// <summary> |
286 | /// Try to get the names bound to the given uuid. | 304 | /// |
287 | /// </summary> | 305 | /// </summary> |
288 | /// <returns>True if the name was found, false if not.</returns> | 306 | /// <param name="uuid"></param> |
289 | /// <param name='uuid'></param> | 307 | /// <param name="names">Caller please provide a properly instantiated array for names, string[2]</param> |
290 | /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> | 308 | /// <returns></returns> |
291 | private bool TryGetUserNames(UUID uuid, out string[] names) | 309 | private bool TryGetUserNames(UUID uuid, string[] names) |
292 | { | 310 | { |
293 | names = new string[2]; | 311 | if (names == null) |
312 | names = new string[2]; | ||
313 | |||
314 | if (TryGetUserNamesFromCache(uuid, names)) | ||
315 | return true; | ||
316 | |||
317 | if (TryGetUserNamesFromServices(uuid, names)) | ||
318 | return true; | ||
319 | |||
320 | return false; | ||
321 | } | ||
294 | 322 | ||
323 | private bool TryGetUserNamesFromCache(UUID uuid, string[] names) | ||
324 | { | ||
295 | lock (m_UserCache) | 325 | lock (m_UserCache) |
296 | { | 326 | { |
297 | if (m_UserCache.ContainsKey(uuid)) | 327 | if (m_UserCache.ContainsKey(uuid)) |
@@ -303,6 +333,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
303 | } | 333 | } |
304 | } | 334 | } |
305 | 335 | ||
336 | return false; | ||
337 | } | ||
338 | |||
339 | /// <summary> | ||
340 | /// Try to get the names bound to the given uuid, from the services. | ||
341 | /// </summary> | ||
342 | /// <returns>True if the name was found, false if not.</returns> | ||
343 | /// <param name='uuid'></param> | ||
344 | /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> | ||
345 | private bool TryGetUserNamesFromServices(UUID uuid, string[] names) | ||
346 | { | ||
306 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); | 347 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); |
307 | 348 | ||
308 | if (account != null) | 349 | if (account != null) |
@@ -387,18 +428,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
387 | 428 | ||
388 | public string GetUserName(UUID uuid) | 429 | public string GetUserName(UUID uuid) |
389 | { | 430 | { |
390 | string[] names; | 431 | string[] names = new string[2]; |
391 | TryGetUserNames(uuid, out names); | 432 | TryGetUserNames(uuid, names); |
392 | 433 | ||
393 | if (names.Length == 2) | 434 | return names[0] + " " + names[1]; |
394 | { | ||
395 | string firstname = names[0]; | ||
396 | string lastname = names[1]; | ||
397 | |||
398 | return firstname + " " + lastname; | ||
399 | } | ||
400 | 435 | ||
401 | return "(hippos)"; | ||
402 | } | 436 | } |
403 | 437 | ||
404 | public string GetUserHomeURL(UUID userID) | 438 | public string GetUserHomeURL(UUID userID) |
@@ -598,13 +632,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
598 | protected void Init() | 632 | protected void Init() |
599 | { | 633 | { |
600 | RegisterConsoleCmds(); | 634 | RegisterConsoleCmds(); |
601 | Watchdog.StartThread( | ||
602 | ProcessQueue, | ||
603 | "NameRequestThread", | ||
604 | ThreadPriority.BelowNormal, | ||
605 | true, | ||
606 | false); | ||
607 | |||
608 | } | 635 | } |
609 | 636 | ||
610 | protected void RegisterConsoleCmds() | 637 | protected void RegisterConsoleCmds() |
@@ -674,39 +701,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
674 | MainConsole.Instance.Output(cdt.ToString()); | 701 | MainConsole.Instance.Output(cdt.ToString()); |
675 | } | 702 | } |
676 | 703 | ||
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 | } | ||
710 | } | 704 | } |
711 | 705 | ||
712 | } \ No newline at end of file | 706 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 2a4d440..1983fed 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -219,7 +219,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
219 | 219 | ||
220 | string uri = "/lslhttp/" + urlcode.ToString(); | 220 | string uri = "/lslhttp/" + urlcode.ToString(); |
221 | 221 | ||
222 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 222 | PollServiceEventArgs args |
223 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | ||
223 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 224 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
224 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); | 225 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
225 | 226 | ||
@@ -266,7 +267,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
266 | 267 | ||
267 | string uri = "/lslhttps/" + urlcode.ToString(); | 268 | string uri = "/lslhttps/" + urlcode.ToString(); |
268 | 269 | ||
269 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 270 | PollServiceEventArgs args |
271 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | ||
270 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 272 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
271 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); | 273 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
272 | 274 | ||