aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IServiceThrottleModule.cs10
3 files changed, 36 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
index a3ca6d6..1554b3e 100644
--- a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
@@ -50,17 +50,15 @@ 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>>();
57 private int m_Interval; 55 private int m_Interval;
58 56
59 #region ISharedRegionModule 57 #region ISharedRegionModule
60 58
61 public void Initialise(IConfigSource config) 59 public void Initialise(IConfigSource config)
62 { 60 {
63 m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 2000); 61 m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 5000);
64 62
65 m_timer = new System.Timers.Timer(); 63 m_timer = new System.Timers.Timer();
66 m_timer.AutoReset = false; 64 m_timer.AutoReset = false;
@@ -159,18 +157,37 @@ namespace OpenSim.Region.CoreModules.Framework
159 client.SendRegionHandle(regionID, r.RegionHandle); 157 client.SendRegionHandle(regionID, r.RegionHandle);
160 }; 158 };
161 159
162 lock (m_RequestQueue) 160 Enqueue("region", regionID.ToString(), action);
163 m_RequestQueue.Enqueue(action);
164
165 } 161 }
166 162
167 #endregion Events 163 #endregion Events
168 164
169 #region IServiceThrottleModule 165 #region IServiceThrottleModule
170 166
171 public void Enqueue(Action continuation) 167 public void Enqueue(string category, string itemid, Action continuation)
172 { 168 {
173 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 continuation();
185 lock (m_RequestQueue)
186 {
187 m_Pending[category].Remove(itemid);
188 }
189 });
190 }
174 } 191 }
175 192
176 #endregion IServiceThrottleModule 193 #endregion IServiceThrottleModule
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index e8bdcc9..a91adfa 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
173 } 173 }
174 174
175 // Not found in cache, queue continuation 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 = TryGetUserNames(uuid, names); 179 bool foundRealName = TryGetUserNames(uuid, names);
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}