diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | 150 |
1 files changed, 104 insertions, 46 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 817ef85..c0afe7c 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -47,23 +47,23 @@ namespace OpenSim.Region.CoreModules.Framework | |||
47 | { | 47 | { |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CapabilitiesModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CapabilitiesModule")] |
49 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule | 49 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private string m_showCapsCommandFormat = " {0,-38} {1,-60}\n"; | 53 | private string m_showCapsCommandFormat = " {0,-38} {1,-60}\n"; |
54 | 54 | ||
55 | protected Scene m_scene; | 55 | protected Scene m_scene; |
56 | 56 | ||
57 | /// <summary> | 57 | /// <summary> |
58 | /// Each agent has its own capabilities handler. | 58 | /// Each agent has its own capabilities handler. |
59 | /// </summary> | 59 | /// </summary> |
60 | protected Dictionary<UUID, Caps> m_capsObjects = new Dictionary<UUID, Caps>(); | 60 | protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); |
61 | 61 | ||
62 | protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); | 62 | protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>(); |
63 | 63 | ||
64 | protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds | 64 | protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds |
65 | = new Dictionary<UUID, Dictionary<ulong, string>>(); | 65 | = new Dictionary<UUID, Dictionary<ulong, string>>(); |
66 | 66 | ||
67 | public void Initialise(IConfigSource source) | 67 | public void Initialise(IConfigSource source) |
68 | { | 68 | { |
69 | } | 69 | } |
@@ -101,16 +101,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
101 | { | 101 | { |
102 | m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this); | 102 | m_scene.UnregisterModuleInterface<ICapabilitiesModule>(this); |
103 | } | 103 | } |
104 | 104 | ||
105 | public void PostInitialise() | 105 | public void PostInitialise() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | public void Close() {} | 109 | public void Close() {} |
110 | 110 | ||
111 | public string Name | 111 | public string Name |
112 | { | 112 | { |
113 | get { return "Capabilities Module"; } | 113 | get { return "Capabilities Module"; } |
114 | } | 114 | } |
115 | 115 | ||
116 | public Type ReplaceableInterface | 116 | public Type ReplaceableInterface |
@@ -118,23 +118,46 @@ namespace OpenSim.Region.CoreModules.Framework | |||
118 | get { return null; } | 118 | get { return null; } |
119 | } | 119 | } |
120 | 120 | ||
121 | public void CreateCaps(UUID agentId) | 121 | public void CreateCaps(UUID agentId, uint circuitCode) |
122 | { | 122 | { |
123 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) | 123 | int ts = Util.EnvironmentTickCount(); |
124 | return; | 124 | /* this as no business here... |
125 | * must be done elsewhere ( and is ) | ||
126 | int flags = m_scene.GetUserFlags(agentId); | ||
127 | |||
128 | m_log.ErrorFormat("[CreateCaps]: banCheck {0} ", Util.EnvironmentTickCountSubtract(ts)); | ||
125 | 129 | ||
130 | if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) | ||
131 | return; | ||
132 | */ | ||
126 | Caps caps; | 133 | Caps caps; |
127 | String capsObjectPath = GetCapsPath(agentId); | 134 | String capsObjectPath = GetCapsPath(agentId); |
128 | 135 | ||
129 | lock (m_capsObjects) | 136 | lock (m_capsObjects) |
130 | { | 137 | { |
131 | if (m_capsObjects.ContainsKey(agentId)) | 138 | if (m_capsObjects.ContainsKey(circuitCode)) |
132 | { | 139 | { |
133 | Caps oldCaps = m_capsObjects[agentId]; | 140 | Caps oldCaps = m_capsObjects[circuitCode]; |
134 | 141 | ||
135 | //m_log.WarnFormat( | 142 | |
136 | // "[CAPS]: Recreating caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ", | 143 | if (capsObjectPath == oldCaps.CapsObjectPath) |
137 | // agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath); | 144 | { |
145 | // m_log.WarnFormat( | ||
146 | // "[CAPS]: Reusing caps for agent {0} in region {1}. Old caps path {2}, new caps path {3}. ", | ||
147 | // agentId, m_scene.RegionInfo.RegionName, oldCaps.CapsObjectPath, capsObjectPath); | ||
148 | return; | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | // not reusing add extra melanie cleanup | ||
153 | // Remove tge handlers. They may conflict with the | ||
154 | // new object created below | ||
155 | oldCaps.DeregisterHandlers(); | ||
156 | |||
157 | // Better safe ... should not be needed but also | ||
158 | // no big deal | ||
159 | m_capsObjects.Remove(circuitCode); | ||
160 | } | ||
138 | } | 161 | } |
139 | 162 | ||
140 | // m_log.DebugFormat( | 163 | // m_log.DebugFormat( |
@@ -145,13 +168,17 @@ namespace OpenSim.Region.CoreModules.Framework | |||
145 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, | 168 | (MainServer.Instance == null) ? 0: MainServer.Instance.Port, |
146 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); | 169 | capsObjectPath, agentId, m_scene.RegionInfo.RegionName); |
147 | 170 | ||
148 | m_capsObjects[agentId] = caps; | 171 | m_log.DebugFormat("[CreateCaps]: new caps agent {0}, circuit {1}, path {2}, time {3} ",agentId, |
149 | } | 172 | circuitCode,caps.CapsObjectPath, Util.EnvironmentTickCountSubtract(ts)); |
150 | 173 | ||
174 | m_capsObjects[circuitCode] = caps; | ||
175 | } | ||
151 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); | 176 | m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); |
177 | // m_log.ErrorFormat("[CreateCaps]: end {0} ", Util.EnvironmentTickCountSubtract(ts)); | ||
178 | |||
152 | } | 179 | } |
153 | 180 | ||
154 | public void RemoveCaps(UUID agentId) | 181 | public void RemoveCaps(UUID agentId, uint circuitCode) |
155 | { | 182 | { |
156 | m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); | 183 | m_log.DebugFormat("[CAPS]: Remove caps for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); |
157 | lock (m_childrenSeeds) | 184 | lock (m_childrenSeeds) |
@@ -164,44 +191,65 @@ namespace OpenSim.Region.CoreModules.Framework | |||
164 | 191 | ||
165 | lock (m_capsObjects) | 192 | lock (m_capsObjects) |
166 | { | 193 | { |
167 | if (m_capsObjects.ContainsKey(agentId)) | 194 | if (m_capsObjects.ContainsKey(circuitCode)) |
168 | { | 195 | { |
169 | m_capsObjects[agentId].DeregisterHandlers(); | 196 | m_capsObjects[circuitCode].DeregisterHandlers(); |
170 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[agentId]); | 197 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsObjects[circuitCode]); |
171 | m_capsObjects.Remove(agentId); | 198 | m_capsObjects.Remove(circuitCode); |
172 | } | 199 | } |
173 | else | 200 | else |
174 | { | 201 | { |
202 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) | ||
203 | { | ||
204 | if (kvp.Value.AgentID == agentId) | ||
205 | { | ||
206 | kvp.Value.DeregisterHandlers(); | ||
207 | m_scene.EventManager.TriggerOnDeregisterCaps(agentId, kvp.Value); | ||
208 | m_capsObjects.Remove(kvp.Key); | ||
209 | return; | ||
210 | } | ||
211 | } | ||
175 | m_log.WarnFormat( | 212 | m_log.WarnFormat( |
176 | "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", | 213 | "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", |
177 | agentId, m_scene.RegionInfo.RegionName); | 214 | agentId, m_scene.RegionInfo.RegionName); |
178 | } | 215 | } |
179 | } | 216 | } |
180 | } | 217 | } |
181 | 218 | ||
182 | public Caps GetCapsForUser(UUID agentId) | 219 | public Caps GetCapsForUser(uint circuitCode) |
183 | { | 220 | { |
184 | lock (m_capsObjects) | 221 | lock (m_capsObjects) |
185 | { | 222 | { |
186 | if (m_capsObjects.ContainsKey(agentId)) | 223 | if (m_capsObjects.ContainsKey(circuitCode)) |
187 | { | 224 | { |
188 | return m_capsObjects[agentId]; | 225 | return m_capsObjects[circuitCode]; |
189 | } | 226 | } |
190 | } | 227 | } |
191 | 228 | ||
192 | return null; | 229 | return null; |
193 | } | 230 | } |
194 | 231 | ||
232 | public void ActivateCaps(uint circuitCode) | ||
233 | { | ||
234 | lock (m_capsObjects) | ||
235 | { | ||
236 | if (m_capsObjects.ContainsKey(circuitCode)) | ||
237 | { | ||
238 | m_capsObjects[circuitCode].Activate(); | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | |||
195 | public void SetAgentCapsSeeds(AgentCircuitData agent) | 243 | public void SetAgentCapsSeeds(AgentCircuitData agent) |
196 | { | 244 | { |
197 | lock (m_capsPaths) | 245 | lock (m_capsPaths) |
198 | m_capsPaths[agent.AgentID] = agent.CapsPath; | 246 | m_capsPaths[agent.AgentID] = agent.CapsPath; |
199 | 247 | ||
200 | lock (m_childrenSeeds) | 248 | lock (m_childrenSeeds) |
201 | m_childrenSeeds[agent.AgentID] | 249 | m_childrenSeeds[agent.AgentID] |
202 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); | 250 | = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); |
203 | } | 251 | } |
204 | 252 | ||
205 | public string GetCapsPath(UUID agentId) | 253 | public string GetCapsPath(UUID agentId) |
206 | { | 254 | { |
207 | lock (m_capsPaths) | 255 | lock (m_capsPaths) |
@@ -214,7 +262,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
214 | 262 | ||
215 | return null; | 263 | return null; |
216 | } | 264 | } |
217 | 265 | ||
218 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) | 266 | public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) |
219 | { | 267 | { |
220 | Dictionary<ulong, string> seeds = null; | 268 | Dictionary<ulong, string> seeds = null; |
@@ -289,9 +337,9 @@ namespace OpenSim.Region.CoreModules.Framework | |||
289 | 337 | ||
290 | lock (m_capsObjects) | 338 | lock (m_capsObjects) |
291 | { | 339 | { |
292 | foreach (KeyValuePair<UUID, Caps> kvp in m_capsObjects) | 340 | foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) |
293 | { | 341 | { |
294 | capsReport.AppendFormat("** User {0}:\n", kvp.Key); | 342 | capsReport.AppendFormat("** Circuit {0}:\n", kvp.Key); |
295 | Caps caps = kvp.Value; | 343 | Caps caps = kvp.Value; |
296 | 344 | ||
297 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) | 345 | for (IDictionaryEnumerator kvp2 = caps.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) |
@@ -339,6 +387,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
339 | 387 | ||
340 | private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) | 388 | private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) |
341 | { | 389 | { |
390 | /* | ||
342 | sb.AppendFormat("Capability name {0}\n", capName); | 391 | sb.AppendFormat("Capability name {0}\n", capName); |
343 | 392 | ||
344 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | 393 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); |
@@ -365,8 +414,8 @@ namespace OpenSim.Region.CoreModules.Framework | |||
365 | { | 414 | { |
366 | receivedStats[sp.Name] = reqHandler.RequestsReceived; | 415 | receivedStats[sp.Name] = reqHandler.RequestsReceived; |
367 | handledStats[sp.Name] = reqHandler.RequestsHandled; | 416 | handledStats[sp.Name] = reqHandler.RequestsHandled; |
368 | } | 417 | } |
369 | else | 418 | else |
370 | { | 419 | { |
371 | PollServiceEventArgs pollHandler = null; | 420 | PollServiceEventArgs pollHandler = null; |
372 | if (caps.TryGetPollHandler(capName, out pollHandler)) | 421 | if (caps.TryGetPollHandler(capName, out pollHandler)) |
@@ -384,10 +433,12 @@ namespace OpenSim.Region.CoreModules.Framework | |||
384 | } | 433 | } |
385 | 434 | ||
386 | sb.Append(cdt.ToString()); | 435 | sb.Append(cdt.ToString()); |
436 | */ | ||
387 | } | 437 | } |
388 | 438 | ||
389 | private void BuildSummaryStatsByCapReport(StringBuilder sb) | 439 | private void BuildSummaryStatsByCapReport(StringBuilder sb) |
390 | { | 440 | { |
441 | /* | ||
391 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | 442 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); |
392 | cdt.AddColumn("Name", 34); | 443 | cdt.AddColumn("Name", 34); |
393 | cdt.AddColumn("Req Received", 12); | 444 | cdt.AddColumn("Req Received", 12); |
@@ -403,7 +454,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
403 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); | 454 | Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID); |
404 | 455 | ||
405 | if (caps == null) | 456 | if (caps == null) |
406 | return; | 457 | return; |
407 | 458 | ||
408 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) | 459 | foreach (IRequestHandler reqHandler in caps.CapsHandlers.GetCapsHandlers().Values) |
409 | { | 460 | { |
@@ -439,15 +490,17 @@ namespace OpenSim.Region.CoreModules.Framework | |||
439 | } | 490 | } |
440 | } | 491 | } |
441 | ); | 492 | ); |
442 | 493 | ||
443 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) | 494 | foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value)) |
444 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); | 495 | cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]); |
445 | 496 | ||
446 | sb.Append(cdt.ToString()); | 497 | sb.Append(cdt.ToString()); |
498 | */ | ||
447 | } | 499 | } |
448 | 500 | ||
449 | private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) | 501 | private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) |
450 | { | 502 | { |
503 | /* | ||
451 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) | 504 | if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) |
452 | return; | 505 | return; |
453 | 506 | ||
@@ -478,10 +531,12 @@ namespace OpenSim.Region.CoreModules.Framework | |||
478 | } | 531 | } |
479 | 532 | ||
480 | MainConsole.Instance.Output(sb.ToString()); | 533 | MainConsole.Instance.Output(sb.ToString()); |
534 | */ | ||
481 | } | 535 | } |
482 | 536 | ||
483 | private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) | 537 | private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) |
484 | { | 538 | { |
539 | /* | ||
485 | sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); | 540 | sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root"); |
486 | 541 | ||
487 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | 542 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); |
@@ -504,13 +559,15 @@ namespace OpenSim.Region.CoreModules.Framework | |||
504 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); | 559 | capRows.Add(new CapTableRow(kvp.Key, kvp.Value.RequestsReceived, kvp.Value.RequestsHandled)); |
505 | 560 | ||
506 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) | 561 | foreach (CapTableRow ctr in capRows.OrderByDescending(ctr => ctr.RequestsReceived)) |
507 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); | 562 | cdt.AddRow(ctr.Name, ctr.RequestsReceived, ctr.RequestsHandled); |
508 | 563 | ||
509 | sb.Append(cdt.ToString()); | 564 | sb.Append(cdt.ToString()); |
565 | */ | ||
510 | } | 566 | } |
511 | 567 | ||
512 | private void BuildSummaryStatsByUserReport(StringBuilder sb) | 568 | private void BuildSummaryStatsByUserReport(StringBuilder sb) |
513 | { | 569 | { |
570 | /* | ||
514 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); | 571 | ConsoleDisplayTable cdt = new ConsoleDisplayTable(); |
515 | cdt.AddColumn("Name", 32); | 572 | cdt.AddColumn("Name", 32); |
516 | cdt.AddColumn("Type", 5); | 573 | cdt.AddColumn("Type", 5); |
@@ -544,12 +601,13 @@ namespace OpenSim.Region.CoreModules.Framework | |||
544 | totalRequestsReceived += handler.RequestsReceived; | 601 | totalRequestsReceived += handler.RequestsReceived; |
545 | totalRequestsHandled += handler.RequestsHandled; | 602 | totalRequestsHandled += handler.RequestsHandled; |
546 | } | 603 | } |
547 | 604 | ||
548 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); | 605 | cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled); |
549 | } | 606 | } |
550 | ); | 607 | ); |
551 | 608 | ||
552 | sb.Append(cdt.ToString()); | 609 | sb.Append(cdt.ToString()); |
610 | */ | ||
553 | } | 611 | } |
554 | 612 | ||
555 | private class CapTableRow | 613 | private class CapTableRow |
@@ -566,4 +624,4 @@ namespace OpenSim.Region.CoreModules.Framework | |||
566 | } | 624 | } |
567 | } | 625 | } |
568 | } | 626 | } |
569 | } \ No newline at end of file | 627 | } |