aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs52
-rw-r--r--OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs140
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs7
3 files changed, 24 insertions, 175 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 65a341e..f472dba 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -9614,61 +9614,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9614 9614
9615 #region Parcel related packets 9615 #region Parcel related packets
9616 9616
9617 // acumulate several HandleRegionHandleRequest consecutive overlaping requests
9618 // to be done with minimal resources as possible
9619 // variables temporary here while in test
9620
9621 Queue<UUID> RegionHandleRequests = new Queue<UUID>();
9622 bool RegionHandleRequestsInService = false;
9623
9624 private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack) 9617 private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
9625 { 9618 {
9626 UUID currentUUID;
9627
9628 RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest; 9619 RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
9629 9620
9630 if (handlerRegionHandleRequest == null) 9621 if (handlerRegionHandleRequest != null)
9631 return true;
9632
9633 RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
9634
9635 lock (RegionHandleRequests)
9636 { 9622 {
9637 if (RegionHandleRequestsInService) 9623 RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
9638 { 9624 handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
9639 // we are already busy doing a previus request
9640 // so enqueue it
9641 RegionHandleRequests.Enqueue(rhrPack.RequestBlock.RegionID);
9642 return true;
9643 }
9644
9645 // else do it
9646 currentUUID = rhrPack.RequestBlock.RegionID;
9647 RegionHandleRequestsInService = true;
9648 } 9625 }
9649 9626
9650 while (true) 9627 return true;
9651 {
9652 handlerRegionHandleRequest(this, currentUUID);
9653
9654 lock (RegionHandleRequests)
9655 {
9656 // exit condition, nothing to do or closed
9657 // current code seems to assume we may loose the handler at anytime,
9658 // so keep checking it
9659 handlerRegionHandleRequest = OnRegionHandleRequest;
9660
9661 if (RegionHandleRequests.Count == 0 || !IsActive || handlerRegionHandleRequest == null)
9662 {
9663 RegionHandleRequests.Clear();
9664 RegionHandleRequestsInService = false;
9665 return true;
9666 }
9667 currentUUID = RegionHandleRequests.Dequeue();
9668 }
9669 }
9670
9671 return true; // actually unreached
9672 } 9628 }
9673 9629
9674 private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack) 9630 private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
diff --git a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
index 3abacbd..36fb57a 100644
--- a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
@@ -48,31 +48,16 @@ namespace OpenSim.Region.CoreModules.Framework
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 private JobEngine m_processorJobEngine;
52 52
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 #region ISharedRegionModule
58 54
59 public void Initialise(IConfigSource config) 55 public void Initialise(IConfigSource config)
60 { 56 {
61 m_Interval = Util.GetConfigVarFromSections<int>(config, "Interval", new string[] { "ServiceThrottle" }, 5000); 57 m_processorJobEngine = new JobEngine(
62 58 "ServiceThrottle","ServiceThrottle");
63 m_timer = new System.Timers.Timer(); 59 m_processorJobEngine.RequestProcessTimeoutOnStop = 31000; // many webrequests have 30s expire
64 m_timer.AutoReset = false; 60 m_processorJobEngine.Start();
65 m_timer.Enabled = true;
66 m_timer.Interval = 15000; // 15 secs at first
67 m_timer.Elapsed += ProcessQueue;
68 m_timer.Start();
69
70 //WorkManager.StartThread(
71 // ProcessQueue,
72 // "GridServiceRequestThread",
73 // ThreadPriority.BelowNormal,
74 // true,
75 // false);
76 } 61 }
77 62
78 public void AddRegion(Scene scene) 63 public void AddRegion(Scene scene)
@@ -82,7 +67,6 @@ namespace OpenSim.Region.CoreModules.Framework
82 m_scenes.Add(scene); 67 m_scenes.Add(scene);
83 scene.RegisterModuleInterface<IServiceThrottleModule>(this); 68 scene.RegisterModuleInterface<IServiceThrottleModule>(this);
84 scene.EventManager.OnNewClient += OnNewClient; 69 scene.EventManager.OnNewClient += OnNewClient;
85 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
86 } 70 }
87 } 71 }
88 72
@@ -105,6 +89,7 @@ namespace OpenSim.Region.CoreModules.Framework
105 89
106 public void Close() 90 public void Close()
107 { 91 {
92 m_processorJobEngine.Stop();
108 } 93 }
109 94
110 public string Name 95 public string Name
@@ -126,38 +111,24 @@ namespace OpenSim.Region.CoreModules.Framework
126 client.OnRegionHandleRequest += OnRegionHandleRequest; 111 client.OnRegionHandleRequest += OnRegionHandleRequest;
127 } 112 }
128 113
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
142 public void OnRegionHandleRequest(IClientAPI client, UUID regionID) 114 public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
143 { 115 {
144 //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID); 116 //m_log.DebugFormat("[SERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
145 ulong handle = 0;
146 if (IsLocalRegionHandle(regionID, out handle))
147 {
148 client.SendRegionHandle(regionID, handle);
149 return;
150 }
151
152 Action action = delegate 117 Action action = delegate
153 { 118 {
119 if(!client.IsActive)
120 return;
121
154 GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID); 122 GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID);
155 123
124 if(!client.IsActive)
125 return;
126
156 if (r != null && r.RegionHandle != 0) 127 if (r != null && r.RegionHandle != 0)
157 client.SendRegionHandle(regionID, r.RegionHandle); 128 client.SendRegionHandle(regionID, r.RegionHandle);
158 }; 129 };
159 130
160 Enqueue("region", regionID.ToString(), action); 131 m_processorJobEngine.QueueJob("regionHandle", action, regionID.ToString());
161 } 132 }
162 133
163 #endregion Events 134 #endregion Events
@@ -166,91 +137,10 @@ namespace OpenSim.Region.CoreModules.Framework
166 137
167 public void Enqueue(string category, string itemid, Action continuation) 138 public void Enqueue(string category, string itemid, Action continuation)
168 { 139 {
169 lock (m_RequestQueue) 140 m_processorJobEngine.QueueJob(category, continuation, itemid);
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 } 141 }
191 142
192 #endregion IServiceThrottleModule 143 #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;
222
223 }
224
225 #endregion Process Continuation Queue
226
227 #region Misc
228
229 private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle)
230 {
231 regionHandle = 0;
232 foreach (Scene s in m_scenes)
233 if (s.RegionInfo.RegionID == regionID)
234 {
235 regionHandle = s.RegionInfo.RegionHandle;
236 return true;
237 }
238 return false;
239 }
240
241 private bool AreThereRootAgents()
242 {
243 foreach (Scene s in m_scenes)
244 {
245 foreach (ScenePresence sp in s.GetScenePresences())
246 if (!sp.IsChildAgent)
247 return true;
248 }
249
250 return false;
251 }
252
253 #endregion Misc
254 } 144 }
255 145
256} 146}
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 72fff22..5507526 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
206 } 206 }
207 207
208 // Not found in cache, queue continuation 208 // Not found in cache, queue continuation
209 m_ServiceThrottle.Enqueue("name", uuid.ToString(), delegate 209 m_ServiceThrottle.Enqueue("uuidname", uuid.ToString(), delegate
210 { 210 {
211 //m_log.DebugFormat("[YYY]: Name request {0}", uuid); 211 //m_log.DebugFormat("[YYY]: Name request {0}", uuid);
212 212
@@ -216,9 +216,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
216 // So to avoid clients 216 // So to avoid clients
217 // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will 217 // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will
218 // instead drop the request entirely. 218 // instead drop the request entirely.
219 if(!client.IsActive)
220 return;
219 if (GetUser(uuid, out user)) 221 if (GetUser(uuid, out user))
220 { 222 {
221 client.SendNameReply(uuid, user.FirstName, user.LastName); 223 if(client.IsActive)
224 client.SendNameReply(uuid, user.FirstName, user.LastName);
222 } 225 }
223// else 226// else
224// m_log.DebugFormat( 227// m_log.DebugFormat(