diff options
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region')
7 files changed, 98 insertions, 28 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 1835a72..f0445ff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -364,8 +364,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | 364 | ||
365 | caps.RegisterPollHandler( | 365 | caps.RegisterPollHandler( |
366 | "EventQueueGet", | 366 | "EventQueueGet", |
367 | new PollServiceEventArgs( | 367 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); |
368 | null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); | ||
369 | 368 | ||
370 | Random rnd = new Random(Environment.TickCount); | 369 | Random rnd = new Random(Environment.TickCount); |
371 | lock (m_ids) | 370 | lock (m_ids) |
@@ -383,7 +382,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
383 | Queue<OSD> queue = GetQueue(agentID); | 382 | Queue<OSD> queue = GetQueue(agentID); |
384 | if (queue != null) | 383 | if (queue != null) |
385 | lock (queue) | 384 | lock (queue) |
385 | { | ||
386 | //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count); | ||
386 | return queue.Count > 0; | 387 | return queue.Count > 0; |
388 | } | ||
387 | 389 | ||
388 | return false; | 390 | return false; |
389 | } | 391 | } |
@@ -406,7 +408,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
406 | public Hashtable GetEvents(UUID requestID, UUID pAgentId) | 408 | public Hashtable GetEvents(UUID requestID, UUID pAgentId) |
407 | { | 409 | { |
408 | if (DebugLevel >= 2) | 410 | if (DebugLevel >= 2) |
409 | m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); | 411 | m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); |
410 | 412 | ||
411 | Queue<OSD> queue = TryGetQueue(pAgentId); | 413 | Queue<OSD> queue = TryGetQueue(pAgentId); |
412 | OSD element; | 414 | OSD element; |
diff --git a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs index 553e4ca..a70261e 100644 --- a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs | |||
@@ -50,15 +50,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
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 | private System.Timers.Timer m_timer = new System.Timers.Timer(); |
52 | 52 | ||
53 | //private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); | ||
54 | // private OpenSim.Framework.DoubleQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<GridRegionRequest>(); | ||
55 | //private Queue<GridRegionRequest> m_RequestQueue = new Queue<GridRegionRequest>(); | ||
56 | private Queue<Action> m_RequestQueue = new Queue<Action>(); | 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; | ||
57 | 56 | ||
58 | #region ISharedRegionModule | 57 | #region ISharedRegionModule |
59 | 58 | ||
60 | public void Initialise(IConfigSource config) | 59 | public void Initialise(IConfigSource config) |
61 | { | 60 | { |
61 | m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 5000); | ||
62 | |||
62 | m_timer = new System.Timers.Timer(); | 63 | m_timer = new System.Timers.Timer(); |
63 | m_timer.AutoReset = false; | 64 | m_timer.AutoReset = false; |
64 | m_timer.Enabled = true; | 65 | m_timer.Enabled = true; |
@@ -131,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
131 | { | 132 | { |
132 | if (!m_timer.Enabled) | 133 | if (!m_timer.Enabled) |
133 | { | 134 | { |
134 | m_timer.Interval = 1000; | 135 | m_timer.Interval = m_Interval; |
135 | m_timer.Enabled = true; | 136 | m_timer.Enabled = true; |
136 | m_timer.Start(); | 137 | m_timer.Start(); |
137 | } | 138 | } |
@@ -156,18 +157,36 @@ namespace OpenSim.Region.CoreModules.Framework | |||
156 | client.SendRegionHandle(regionID, r.RegionHandle); | 157 | client.SendRegionHandle(regionID, r.RegionHandle); |
157 | }; | 158 | }; |
158 | 159 | ||
159 | lock (m_RequestQueue) | 160 | Enqueue("region", regionID.ToString(), action); |
160 | m_RequestQueue.Enqueue(action); | ||
161 | |||
162 | } | 161 | } |
163 | 162 | ||
164 | #endregion Events | 163 | #endregion Events |
165 | 164 | ||
166 | #region IServiceThrottleModule | 165 | #region IServiceThrottleModule |
167 | 166 | ||
168 | public void Enqueue(Action continuation) | 167 | public void Enqueue(string category, string itemid, Action continuation) |
169 | { | 168 | { |
170 | m_RequestQueue.Enqueue(continuation); | 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 | } | ||
171 | } | 190 | } |
172 | 191 | ||
173 | #endregion IServiceThrottleModule | 192 | #endregion IServiceThrottleModule |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index da28a53..a91adfa 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -172,11 +172,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | 174 | ||
175 | // Not found in cache, get it from services | 175 | // Not found in cache, queue continuation |
176 | m_ServiceThrottle.Enqueue(delegate | 176 | m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate |
177 | { | 177 | { |
178 | //m_log.DebugFormat("[YYY]: Name request {0}", uuid); | 178 | //m_log.DebugFormat("[YYY]: Name request {0}", uuid); |
179 | bool foundRealName = TryGetUserNamesFromServices(uuid, names); | 179 | bool foundRealName = TryGetUserNames(uuid, names); |
180 | 180 | ||
181 | if (names.Length == 2) | 181 | if (names.Length == 2) |
182 | { | 182 | { |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index c50ab64..a26a5f0 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -81,6 +81,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
81 | private List<UUID> m_rootAgents = new List<UUID>(); | 81 | private List<UUID> m_rootAgents = new List<UUID>(); |
82 | private volatile bool threadrunning = false; | 82 | private volatile bool threadrunning = false; |
83 | 83 | ||
84 | private IServiceThrottleModule m_ServiceThrottle; | ||
85 | |||
84 | //private int CacheRegionsDistance = 256; | 86 | //private int CacheRegionsDistance = 256; |
85 | 87 | ||
86 | #region INonSharedRegionModule Members | 88 | #region INonSharedRegionModule Members |
@@ -131,6 +133,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
131 | 133 | ||
132 | public virtual void RegionLoaded (Scene scene) | 134 | public virtual void RegionLoaded (Scene scene) |
133 | { | 135 | { |
136 | if (!m_Enabled) | ||
137 | return; | ||
138 | |||
139 | m_ServiceThrottle = scene.RequestModuleInterface<IServiceThrottleModule>(); | ||
134 | } | 140 | } |
135 | 141 | ||
136 | 142 | ||
@@ -170,13 +176,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
170 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; | 176 | m_scene.EventManager.OnMakeRootAgent += MakeRootAgent; |
171 | m_scene.EventManager.OnRegionUp += OnRegionUp; | 177 | m_scene.EventManager.OnRegionUp += OnRegionUp; |
172 | 178 | ||
173 | StartThread(new object()); | 179 | // StartThread(new object()); |
174 | } | 180 | } |
175 | 181 | ||
176 | // this has to be called with a lock on m_scene | 182 | // this has to be called with a lock on m_scene |
177 | protected virtual void RemoveHandlers() | 183 | protected virtual void RemoveHandlers() |
178 | { | 184 | { |
179 | StopThread(); | 185 | // StopThread(); |
180 | 186 | ||
181 | m_scene.EventManager.OnRegionUp -= OnRegionUp; | 187 | m_scene.EventManager.OnRegionUp -= OnRegionUp; |
182 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; | 188 | m_scene.EventManager.OnMakeRootAgent -= MakeRootAgent; |
@@ -526,7 +532,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
526 | /// </summary> | 532 | /// </summary> |
527 | public void process() | 533 | public void process() |
528 | { | 534 | { |
529 | const int MAX_ASYNC_REQUESTS = 20; | 535 | //const int MAX_ASYNC_REQUESTS = 20; |
530 | try | 536 | try |
531 | { | 537 | { |
532 | while (true) | 538 | while (true) |
@@ -571,13 +577,44 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
571 | Watchdog.RemoveThread(); | 577 | Watchdog.RemoveThread(); |
572 | } | 578 | } |
573 | 579 | ||
580 | const int MAX_ASYNC_REQUESTS = 20; | ||
581 | |||
574 | /// <summary> | 582 | /// <summary> |
575 | /// Enqueues the map item request into the processing thread | 583 | /// Enqueues the map item request into the services throttle processing thread |
576 | /// </summary> | 584 | /// </summary> |
577 | /// <param name="state"></param> | 585 | /// <param name="state"></param> |
578 | public void EnqueueMapItemRequest(MapRequestState state) | 586 | public void EnqueueMapItemRequest(MapRequestState st) |
579 | { | 587 | { |
580 | requests.Enqueue(state); | 588 | |
589 | m_ServiceThrottle.Enqueue("map-item", st.regionhandle.ToString() + st.agentID.ToString(), delegate | ||
590 | { | ||
591 | if (st.agentID != UUID.Zero) | ||
592 | { | ||
593 | bool dorequest = true; | ||
594 | lock (m_rootAgents) | ||
595 | { | ||
596 | if (!m_rootAgents.Contains(st.agentID)) | ||
597 | dorequest = false; | ||
598 | } | ||
599 | |||
600 | if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) | ||
601 | { | ||
602 | if (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break | ||
603 | { | ||
604 | // AH!!! Recursive ! | ||
605 | // Put this request back in the queue and return | ||
606 | EnqueueMapItemRequest(st); | ||
607 | return; | ||
608 | } | ||
609 | |||
610 | RequestMapItemsDelegate d = RequestMapItemsAsync; | ||
611 | d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null); | ||
612 | //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); | ||
613 | //RequestMapItemsCompleted(response); | ||
614 | Interlocked.Increment(ref nAsyncRequests); | ||
615 | } | ||
616 | } | ||
617 | }); | ||
581 | } | 618 | } |
582 | 619 | ||
583 | /// <summary> | 620 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IServiceThrottleModule.cs b/OpenSim/Region/Framework/Interfaces/IServiceThrottleModule.cs index bb6a8b4..198256f 100644 --- a/OpenSim/Region/Framework/Interfaces/IServiceThrottleModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IServiceThrottleModule.cs | |||
@@ -5,7 +5,15 @@ namespace OpenSim.Region.Framework.Interfaces | |||
5 | { | 5 | { |
6 | public interface IServiceThrottleModule | 6 | public interface IServiceThrottleModule |
7 | { | 7 | { |
8 | void Enqueue(Action continuation); | 8 | /// <summary> |
9 | /// Enqueue a continuation meant to get a resource from elsewhere. | ||
10 | /// As usual with CPS, caller beware: if that continuation is a never-ending computation, | ||
11 | /// the whole thread will be blocked, and no requests are processed | ||
12 | /// </summary> | ||
13 | /// <param name="category">Category of the resource (e.g. name, region)</param> | ||
14 | /// <param name="itemid">The resource identifier</param> | ||
15 | /// <param name="continuation">The continuation to be executed</param> | ||
16 | void Enqueue(string category, string itemid, Action continuation); | ||
9 | } | 17 | } |
10 | 18 | ||
11 | } | 19 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index a41eaf8..fc4545f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -103,9 +103,10 @@ public abstract class BSPhysObject : PhysicsActor | |||
103 | CollisionsLastTickStep = -1; | 103 | CollisionsLastTickStep = -1; |
104 | 104 | ||
105 | SubscribedEventsMs = 0; | 105 | SubscribedEventsMs = 0; |
106 | CollidingStep = 0; | 106 | // Crazy values that will never be true |
107 | CollidingGroundStep = 0; | 107 | CollidingStep = BSScene.NotASimulationStep; |
108 | CollisionAccumulation = 0; | 108 | CollidingGroundStep = BSScene.NotASimulationStep; |
109 | CollisionAccumulation = BSScene.NotASimulationStep; | ||
109 | ColliderIsMoving = false; | 110 | ColliderIsMoving = false; |
110 | CollisionScore = 0; | 111 | CollisionScore = 0; |
111 | 112 | ||
@@ -349,7 +350,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
349 | if (value) | 350 | if (value) |
350 | CollidingStep = PhysScene.SimulationStep; | 351 | CollidingStep = PhysScene.SimulationStep; |
351 | else | 352 | else |
352 | CollidingStep = 0; | 353 | CollidingStep = BSScene.NotASimulationStep; |
353 | } | 354 | } |
354 | } | 355 | } |
355 | public override bool CollidingGround { | 356 | public override bool CollidingGround { |
@@ -359,7 +360,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
359 | if (value) | 360 | if (value) |
360 | CollidingGroundStep = PhysScene.SimulationStep; | 361 | CollidingGroundStep = PhysScene.SimulationStep; |
361 | else | 362 | else |
362 | CollidingGroundStep = 0; | 363 | CollidingGroundStep = BSScene.NotASimulationStep; |
363 | } | 364 | } |
364 | } | 365 | } |
365 | public override bool CollidingObj { | 366 | public override bool CollidingObj { |
@@ -368,7 +369,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
368 | if (value) | 369 | if (value) |
369 | CollidingObjectStep = PhysScene.SimulationStep; | 370 | CollidingObjectStep = PhysScene.SimulationStep; |
370 | else | 371 | else |
371 | CollidingObjectStep = 0; | 372 | CollidingObjectStep = BSScene.NotASimulationStep; |
372 | } | 373 | } |
373 | } | 374 | } |
374 | 375 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 214271b..41aca3b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -97,6 +97,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
97 | 97 | ||
98 | internal long m_simulationStep = 0; // The current simulation step. | 98 | internal long m_simulationStep = 0; // The current simulation step. |
99 | public long SimulationStep { get { return m_simulationStep; } } | 99 | public long SimulationStep { get { return m_simulationStep; } } |
100 | // A number to use for SimulationStep that is probably not any step value | ||
101 | // Used by the collision code (which remembers the step when a collision happens) to remember not any simulation step. | ||
102 | public static long NotASimulationStep = -1234; | ||
100 | 103 | ||
101 | internal float LastTimeStep { get; private set; } // The simulation time from the last invocation of Simulate() | 104 | internal float LastTimeStep { get; private set; } // The simulation time from the last invocation of Simulate() |
102 | 105 | ||