diff options
Diffstat (limited to 'OpenSim/Region/ClientStack')
4 files changed, 480 insertions, 73 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 0d7b1fc..96b48ad 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -27,11 +27,14 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.IO; | 33 | using System.IO; |
34 | using System.Threading; | ||
33 | using System.Web; | 35 | using System.Web; |
34 | using Mono.Addins; | 36 | using Mono.Addins; |
37 | using OpenSim.Framework.Monitoring; | ||
35 | using log4net; | 38 | using log4net; |
36 | using Nini.Config; | 39 | using Nini.Config; |
37 | using OpenMetaverse; | 40 | using OpenMetaverse; |
@@ -57,8 +60,44 @@ namespace OpenSim.Region.ClientStack.Linden | |||
57 | private IAssetService m_AssetService; | 60 | private IAssetService m_AssetService; |
58 | private bool m_Enabled = true; | 61 | private bool m_Enabled = true; |
59 | private string m_URL; | 62 | private string m_URL; |
63 | |||
64 | struct aPollRequest | ||
65 | { | ||
66 | public PollServiceMeshEventArgs thepoll; | ||
67 | public UUID reqID; | ||
68 | public Hashtable request; | ||
69 | } | ||
70 | |||
71 | public class aPollResponse | ||
72 | { | ||
73 | public Hashtable response; | ||
74 | public int bytes; | ||
75 | public int lod; | ||
76 | } | ||
77 | |||
78 | |||
79 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
80 | |||
81 | private static GetMeshHandler m_getMeshHandler; | ||
82 | |||
83 | private IAssetService m_assetService = null; | ||
84 | |||
85 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); | ||
86 | private static Thread[] m_workerThreads = null; | ||
87 | |||
88 | private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = | ||
89 | new OpenMetaverse.BlockingQueue<aPollRequest>(); | ||
90 | |||
91 | private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>(); | ||
92 | |||
93 | #region ISharedRegionModule Members | ||
94 | |||
95 | ~GetMeshModule() | ||
96 | { | ||
97 | foreach (Thread t in m_workerThreads) | ||
98 | Watchdog.AbortThread(t.ManagedThreadId); | ||
60 | 99 | ||
61 | #region IRegionModuleBase Members | 100 | } |
62 | 101 | ||
63 | public Type ReplaceableInterface | 102 | public Type ReplaceableInterface |
64 | { | 103 | { |
@@ -75,6 +114,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
75 | // Cap doesn't exist | 114 | // Cap doesn't exist |
76 | if (m_URL != string.Empty) | 115 | if (m_URL != string.Empty) |
77 | m_Enabled = true; | 116 | m_Enabled = true; |
117 | |||
78 | } | 118 | } |
79 | 119 | ||
80 | public void AddRegion(Scene pScene) | 120 | public void AddRegion(Scene pScene) |
@@ -83,6 +123,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
83 | return; | 123 | return; |
84 | 124 | ||
85 | m_scene = pScene; | 125 | m_scene = pScene; |
126 | |||
127 | m_assetService = pScene.AssetService; | ||
86 | } | 128 | } |
87 | 129 | ||
88 | public void RemoveRegion(Scene scene) | 130 | public void RemoveRegion(Scene scene) |
@@ -91,6 +133,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
91 | return; | 133 | return; |
92 | 134 | ||
93 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | 135 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; |
136 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; | ||
137 | m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; | ||
138 | |||
94 | m_scene = null; | 139 | m_scene = null; |
95 | } | 140 | } |
96 | 141 | ||
@@ -101,6 +146,27 @@ namespace OpenSim.Region.ClientStack.Linden | |||
101 | 146 | ||
102 | m_AssetService = m_scene.RequestModuleInterface<IAssetService>(); | 147 | m_AssetService = m_scene.RequestModuleInterface<IAssetService>(); |
103 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 148 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
149 | // We'll reuse the same handler for all requests. | ||
150 | m_getMeshHandler = new GetMeshHandler(m_assetService); | ||
151 | m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; | ||
152 | m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; | ||
153 | |||
154 | if (m_workerThreads == null) | ||
155 | { | ||
156 | m_workerThreads = new Thread[2]; | ||
157 | |||
158 | for (uint i = 0; i < 2; i++) | ||
159 | { | ||
160 | m_workerThreads[i] = Watchdog.StartThread(DoMeshRequests, | ||
161 | String.Format("MeshWorkerThread{0}", i), | ||
162 | ThreadPriority.Normal, | ||
163 | false, | ||
164 | false, | ||
165 | null, | ||
166 | int.MaxValue); | ||
167 | } | ||
168 | } | ||
169 | |||
104 | } | 170 | } |
105 | 171 | ||
106 | 172 | ||
@@ -110,25 +176,212 @@ namespace OpenSim.Region.ClientStack.Linden | |||
110 | 176 | ||
111 | #endregion | 177 | #endregion |
112 | 178 | ||
179 | private void DoMeshRequests() | ||
180 | { | ||
181 | while (true) | ||
182 | { | ||
183 | aPollRequest poolreq = m_queue.Dequeue(); | ||
184 | |||
185 | poolreq.thepoll.Process(poolreq); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent. | ||
190 | public void ThrottleUpdate(ScenePresence p) | ||
191 | { | ||
192 | byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); | ||
193 | UUID user = p.UUID; | ||
194 | int imagethrottle = ExtractTaskThrottle(throttles); | ||
195 | PollServiceMeshEventArgs args; | ||
196 | if (m_pollservices.TryGetValue(user, out args)) | ||
197 | { | ||
198 | args.UpdateThrottle(imagethrottle, p); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | private int ExtractTaskThrottle(byte[] pthrottles) | ||
203 | { | ||
204 | |||
205 | byte[] adjData; | ||
206 | int pos = 0; | ||
207 | |||
208 | if (!BitConverter.IsLittleEndian) | ||
209 | { | ||
210 | byte[] newData = new byte[7 * 4]; | ||
211 | Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4); | ||
212 | |||
213 | for (int i = 0; i < 7; i++) | ||
214 | Array.Reverse(newData, i * 4, 4); | ||
215 | |||
216 | adjData = newData; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | adjData = pthrottles; | ||
221 | } | ||
222 | |||
223 | // 0.125f converts from bits to bytes | ||
224 | //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
225 | //pos += 4; | ||
226 | // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
227 | //pos += 4; | ||
228 | // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
229 | // pos += 4; | ||
230 | // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
231 | // pos += 4; | ||
232 | pos += 16; | ||
233 | int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
234 | // pos += 4; | ||
235 | //int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; | ||
236 | //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
237 | return task; | ||
238 | } | ||
239 | |||
240 | private class PollServiceMeshEventArgs : PollServiceEventArgs | ||
241 | { | ||
242 | private List<Hashtable> requests = | ||
243 | new List<Hashtable>(); | ||
244 | private Dictionary<UUID, aPollResponse> responses = | ||
245 | new Dictionary<UUID, aPollResponse>(); | ||
246 | |||
247 | private Scene m_scene; | ||
248 | private MeshCapsDataThrottler m_throttler; | ||
249 | public PollServiceMeshEventArgs(UUID pId, Scene scene) : | ||
250 | base(null, null, null, null, pId, int.MaxValue) | ||
251 | { | ||
252 | m_scene = scene; | ||
253 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene); | ||
254 | // x is request id, y is userid | ||
255 | HasEvents = (x, y) => | ||
256 | { | ||
257 | lock (responses) | ||
258 | { | ||
259 | bool ret = m_throttler.hasEvents(x, responses); | ||
260 | m_throttler.ProcessTime(); | ||
261 | return ret; | ||
262 | |||
263 | } | ||
264 | }; | ||
265 | GetEvents = (x, y) => | ||
266 | { | ||
267 | lock (responses) | ||
268 | { | ||
269 | try | ||
270 | { | ||
271 | return responses[x].response; | ||
272 | } | ||
273 | finally | ||
274 | { | ||
275 | m_throttler.ProcessTime(); | ||
276 | responses.Remove(x); | ||
277 | } | ||
278 | } | ||
279 | }; | ||
280 | // x is request id, y is request data hashtable | ||
281 | Request = (x, y) => | ||
282 | { | ||
283 | aPollRequest reqinfo = new aPollRequest(); | ||
284 | reqinfo.thepoll = this; | ||
285 | reqinfo.reqID = x; | ||
286 | reqinfo.request = y; | ||
287 | |||
288 | m_queue.Enqueue(reqinfo); | ||
289 | }; | ||
290 | |||
291 | // this should never happen except possible on shutdown | ||
292 | NoEvents = (x, y) => | ||
293 | { | ||
294 | /* | ||
295 | lock (requests) | ||
296 | { | ||
297 | Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); | ||
298 | requests.Remove(request); | ||
299 | } | ||
300 | */ | ||
301 | Hashtable response = new Hashtable(); | ||
302 | |||
303 | response["int_response_code"] = 500; | ||
304 | response["str_response_string"] = "Script timeout"; | ||
305 | response["content_type"] = "text/plain"; | ||
306 | response["keepalive"] = false; | ||
307 | response["reusecontext"] = false; | ||
308 | |||
309 | return response; | ||
310 | }; | ||
311 | } | ||
312 | |||
313 | public void Process(aPollRequest requestinfo) | ||
314 | { | ||
315 | Hashtable response; | ||
316 | |||
317 | UUID requestID = requestinfo.reqID; | ||
318 | |||
319 | // If the avatar is gone, don't bother to get the texture | ||
320 | if (m_scene.GetScenePresence(Id) == null) | ||
321 | { | ||
322 | response = new Hashtable(); | ||
323 | |||
324 | response["int_response_code"] = 500; | ||
325 | response["str_response_string"] = "Script timeout"; | ||
326 | response["content_type"] = "text/plain"; | ||
327 | response["keepalive"] = false; | ||
328 | response["reusecontext"] = false; | ||
329 | |||
330 | lock (responses) | ||
331 | responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; | ||
332 | |||
333 | return; | ||
334 | } | ||
335 | |||
336 | response = m_getMeshHandler.Handle(requestinfo.request); | ||
337 | lock (responses) | ||
338 | { | ||
339 | responses[requestID] = new aPollResponse() | ||
340 | { | ||
341 | bytes = (int)response["int_bytes"], | ||
342 | lod = (int)response["int_lod"], | ||
343 | response = response | ||
344 | }; | ||
345 | |||
346 | } | ||
347 | m_throttler.ProcessTime(); | ||
348 | } | ||
349 | |||
350 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | ||
351 | { | ||
352 | m_throttler.UpdateThrottle(pimagethrottle, p); | ||
353 | } | ||
354 | } | ||
113 | 355 | ||
114 | public void RegisterCaps(UUID agentID, Caps caps) | 356 | public void RegisterCaps(UUID agentID, Caps caps) |
115 | { | 357 | { |
116 | // UUID capID = UUID.Random(); | 358 | // UUID capID = UUID.Random(); |
117 | |||
118 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | ||
119 | if (m_URL == "localhost") | 359 | if (m_URL == "localhost") |
120 | { | 360 | { |
121 | // m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | 361 | string capUrl = "/CAPS/" + UUID.Random() + "/"; |
122 | GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); | ||
123 | IRequestHandler reqHandler | ||
124 | = new RestHTTPHandler( | ||
125 | "GET", | ||
126 | "/CAPS/" + UUID.Random(), | ||
127 | httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null), | ||
128 | "GetMesh", | ||
129 | agentID.ToString()); | ||
130 | 362 | ||
131 | caps.RegisterHandler("GetMesh", reqHandler); | 363 | // Register this as a poll service |
364 | PollServiceMeshEventArgs args = new PollServiceMeshEventArgs(agentID, m_scene); | ||
365 | |||
366 | args.Type = PollServiceEventArgs.EventType.Mesh; | ||
367 | MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); | ||
368 | |||
369 | string hostName = m_scene.RegionInfo.ExternalHostName; | ||
370 | uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
371 | string protocol = "http"; | ||
372 | |||
373 | if (MainServer.Instance.UseSSL) | ||
374 | { | ||
375 | hostName = MainServer.Instance.SSLCommonName; | ||
376 | port = MainServer.Instance.SSLPort; | ||
377 | protocol = "https"; | ||
378 | } | ||
379 | caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
380 | m_pollservices.Add(agentID, args); | ||
381 | m_capsDict[agentID] = capUrl; | ||
382 | |||
383 | |||
384 | |||
132 | } | 385 | } |
133 | else | 386 | else |
134 | { | 387 | { |
@@ -136,6 +389,143 @@ namespace OpenSim.Region.ClientStack.Linden | |||
136 | caps.RegisterHandler("GetMesh", m_URL); | 389 | caps.RegisterHandler("GetMesh", m_URL); |
137 | } | 390 | } |
138 | } | 391 | } |
392 | private void DeregisterCaps(UUID agentID, Caps caps) | ||
393 | { | ||
394 | string capUrl; | ||
395 | PollServiceMeshEventArgs args; | ||
396 | if (m_capsDict.TryGetValue(agentID, out capUrl)) | ||
397 | { | ||
398 | MainServer.Instance.RemoveHTTPHandler("", capUrl); | ||
399 | m_capsDict.Remove(agentID); | ||
400 | } | ||
401 | if (m_pollservices.TryGetValue(agentID, out args)) | ||
402 | { | ||
403 | m_pollservices.Remove(agentID); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | internal sealed class MeshCapsDataThrottler | ||
408 | { | ||
409 | |||
410 | private volatile int currenttime = 0; | ||
411 | private volatile int lastTimeElapsed = 0; | ||
412 | private volatile int BytesSent = 0; | ||
413 | private int Lod3 = 0; | ||
414 | private int Lod2 = 0; | ||
415 | private int Lod1 = 0; | ||
416 | private int UserSetThrottle = 0; | ||
417 | private int UDPSetThrottle = 0; | ||
418 | private int CapSetThrottle = 0; | ||
419 | private float CapThrottleDistributon = 0.30f; | ||
420 | private readonly Scene m_scene; | ||
421 | private ThrottleOutPacketType Throttle; | ||
422 | |||
423 | public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene) | ||
424 | { | ||
425 | ThrottleBytes = pBytes; | ||
426 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
427 | Throttle = ThrottleOutPacketType.Task; | ||
428 | m_scene = pScene; | ||
429 | } | ||
430 | |||
431 | |||
432 | public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) | ||
433 | { | ||
434 | PassTime(); | ||
435 | // Note, this is called IN LOCK | ||
436 | bool haskey = responses.ContainsKey(key); | ||
437 | if (!haskey) | ||
438 | { | ||
439 | return false; | ||
440 | } | ||
441 | aPollResponse response; | ||
442 | if (responses.TryGetValue(key, out response)) | ||
443 | { | ||
444 | |||
445 | // Normal | ||
446 | if (BytesSent + response.bytes <= ThrottleBytes) | ||
447 | { | ||
448 | BytesSent += response.bytes; | ||
449 | |||
450 | return true; | ||
451 | } | ||
452 | // Lod3 Over | ||
453 | else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1)) | ||
454 | { | ||
455 | Interlocked.Increment(ref Lod3); | ||
456 | BytesSent += response.bytes; | ||
457 | |||
458 | return true; | ||
459 | } | ||
460 | // Lod2 Over | ||
461 | else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1)) | ||
462 | { | ||
463 | Interlocked.Increment(ref Lod2); | ||
464 | BytesSent += response.bytes; | ||
465 | |||
466 | return true; | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | return false; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | return haskey; | ||
475 | } | ||
476 | public void SubtractBytes(int bytes,int lod) | ||
477 | { | ||
478 | BytesSent -= bytes; | ||
479 | } | ||
480 | |||
481 | public void ProcessTime() | ||
482 | { | ||
483 | PassTime(); | ||
484 | } | ||
485 | |||
486 | |||
487 | private void PassTime() | ||
488 | { | ||
489 | currenttime = Util.EnvironmentTickCount(); | ||
490 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | ||
491 | //processTimeBasedActions(responses); | ||
492 | if (currenttime - timeElapsed >= 1000) | ||
493 | { | ||
494 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
495 | BytesSent -= ThrottleBytes; | ||
496 | if (BytesSent < 0) BytesSent = 0; | ||
497 | if (BytesSent < ThrottleBytes) | ||
498 | { | ||
499 | Lod3 = 0; | ||
500 | Lod2 = 0; | ||
501 | Lod1 = 0; | ||
502 | } | ||
503 | } | ||
504 | } | ||
505 | private void AlterThrottle(int setting, ScenePresence p) | ||
506 | { | ||
507 | p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); | ||
508 | } | ||
509 | |||
510 | public int ThrottleBytes | ||
511 | { | ||
512 | get { return CapSetThrottle; } | ||
513 | set { CapSetThrottle = value; } | ||
514 | } | ||
515 | |||
516 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | ||
517 | { | ||
518 | // Client set throttle ! | ||
519 | UserSetThrottle = pimagethrottle; | ||
520 | CapSetThrottle = (int)(pimagethrottle*CapThrottleDistributon); | ||
521 | UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); | ||
522 | if (CapSetThrottle < 4068) | ||
523 | CapSetThrottle = 4068; // at least two discovery mesh | ||
524 | p.ControllingClient.SetAgentThrottleSilent((int) Throttle, UDPSetThrottle); | ||
525 | ProcessTime(); | ||
526 | |||
527 | } | ||
528 | } | ||
139 | 529 | ||
140 | } | 530 | } |
141 | } | 531 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 8cba6c8..c8c709a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -364,80 +364,81 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | poolreq.thepoll.Process(poolreq); | 364 | poolreq.thepoll.Process(poolreq); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | } | 367 | internal sealed class CapsDataThrottler |
368 | |||
369 | internal sealed class CapsDataThrottler | ||
370 | { | ||
371 | |||
372 | private volatile int currenttime = 0; | ||
373 | private volatile int lastTimeElapsed = 0; | ||
374 | private volatile int BytesSent = 0; | ||
375 | private int oversizedImages = 0; | ||
376 | public CapsDataThrottler(int pBytes, int max, int min) | ||
377 | { | ||
378 | ThrottleBytes = pBytes; | ||
379 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
380 | } | ||
381 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) | ||
382 | { | 368 | { |
383 | PassTime(); | 369 | |
384 | // Note, this is called IN LOCK | 370 | private volatile int currenttime = 0; |
385 | bool haskey = responses.ContainsKey(key); | 371 | private volatile int lastTimeElapsed = 0; |
386 | if (!haskey) | 372 | private volatile int BytesSent = 0; |
373 | private int oversizedImages = 0; | ||
374 | public CapsDataThrottler(int pBytes, int max, int min) | ||
387 | { | 375 | { |
388 | return false; | 376 | ThrottleBytes = pBytes; |
377 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
389 | } | 378 | } |
390 | GetTextureModule.aPollResponse response; | 379 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) |
391 | if (responses.TryGetValue(key,out response)) | ||
392 | { | 380 | { |
393 | 381 | PassTime(); | |
394 | // Normal | 382 | // Note, this is called IN LOCK |
395 | if (BytesSent + response.bytes <= ThrottleBytes) | 383 | bool haskey = responses.ContainsKey(key); |
384 | if (!haskey) | ||
396 | { | 385 | { |
397 | BytesSent += response.bytes; | 386 | return false; |
398 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
399 | //m_actions.Add(timeBasedAction); | ||
400 | return true; | ||
401 | } | ||
402 | // Big textures | ||
403 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes%50000) + 1)) | ||
404 | { | ||
405 | Interlocked.Increment(ref oversizedImages); | ||
406 | BytesSent += response.bytes; | ||
407 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
408 | //m_actions.Add(timeBasedAction); | ||
409 | return true; | ||
410 | } | 387 | } |
411 | else | 388 | GetTextureModule.aPollResponse response; |
389 | if (responses.TryGetValue(key, out response)) | ||
412 | { | 390 | { |
413 | return false; | 391 | |
392 | // Normal | ||
393 | if (BytesSent + response.bytes <= ThrottleBytes) | ||
394 | { | ||
395 | BytesSent += response.bytes; | ||
396 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; | ||
397 | //m_actions.Add(timeBasedAction); | ||
398 | return true; | ||
399 | } | ||
400 | // Big textures | ||
401 | else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) | ||
402 | { | ||
403 | Interlocked.Increment(ref oversizedImages); | ||
404 | BytesSent += response.bytes; | ||
405 | //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; | ||
406 | //m_actions.Add(timeBasedAction); | ||
407 | return true; | ||
408 | } | ||
409 | else | ||
410 | { | ||
411 | return false; | ||
412 | } | ||
414 | } | 413 | } |
414 | |||
415 | return haskey; | ||
416 | } | ||
417 | public void ProcessTime() | ||
418 | { | ||
419 | PassTime(); | ||
415 | } | 420 | } |
416 | 421 | ||
417 | return haskey; | 422 | |
418 | } | 423 | private void PassTime() |
419 | public void ProcessTime() | ||
420 | { | ||
421 | PassTime(); | ||
422 | } | ||
423 | |||
424 | |||
425 | private void PassTime() | ||
426 | { | ||
427 | currenttime = Util.EnvironmentTickCount(); | ||
428 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | ||
429 | //processTimeBasedActions(responses); | ||
430 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) | ||
431 | { | 424 | { |
432 | lastTimeElapsed = Util.EnvironmentTickCount(); | 425 | currenttime = Util.EnvironmentTickCount(); |
433 | BytesSent -= ThrottleBytes; | 426 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); |
434 | if (BytesSent < 0) BytesSent = 0; | 427 | //processTimeBasedActions(responses); |
435 | if (BytesSent < ThrottleBytes) | 428 | if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) |
436 | { | 429 | { |
437 | oversizedImages = 0; | 430 | lastTimeElapsed = Util.EnvironmentTickCount(); |
431 | BytesSent -= ThrottleBytes; | ||
432 | if (BytesSent < 0) BytesSent = 0; | ||
433 | if (BytesSent < ThrottleBytes) | ||
434 | { | ||
435 | oversizedImages = 0; | ||
436 | } | ||
438 | } | 437 | } |
439 | } | 438 | } |
439 | public int ThrottleBytes; | ||
440 | } | 440 | } |
441 | public int ThrottleBytes; | ||
442 | } | 441 | } |
442 | |||
443 | |||
443 | } | 444 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index ae9ed7f..533a1a8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -11884,6 +11884,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11884 | } | 11884 | } |
11885 | 11885 | ||
11886 | /// <summary> | 11886 | /// <summary> |
11887 | /// Sets the throttles from values supplied by the client | ||
11888 | /// </summary> | ||
11889 | /// <param name="throttles"></param> | ||
11890 | public void SetAgentThrottleSilent(int throttle, int setting) | ||
11891 | { | ||
11892 | m_udpClient.ForceThrottleSetting(throttle,setting); | ||
11893 | //m_udpClient.SetThrottles(throttles); | ||
11894 | |||
11895 | } | ||
11896 | |||
11897 | |||
11898 | /// <summary> | ||
11887 | /// Get the current throttles for this client as a packed byte array | 11899 | /// Get the current throttles for this client as a packed byte array |
11888 | /// </summary> | 11900 | /// </summary> |
11889 | /// <param name="multiplier">Unused</param> | 11901 | /// <param name="multiplier">Unused</param> |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c472176..f675377 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -682,6 +682,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
682 | if (m_nextOnQueueEmpty == 0) | 682 | if (m_nextOnQueueEmpty == 0) |
683 | m_nextOnQueueEmpty = 1; | 683 | m_nextOnQueueEmpty = 1; |
684 | } | 684 | } |
685 | internal void ForceThrottleSetting(int throttle, int setting) | ||
686 | { | ||
687 | m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); ; | ||
688 | } | ||
685 | 689 | ||
686 | /// <summary> | 690 | /// <summary> |
687 | /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a | 691 | /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a |