diff options
author | UbitUmarov | 2018-10-08 17:29:42 +0100 |
---|---|---|
committer | UbitUmarov | 2018-10-08 17:29:42 +0100 |
commit | 57ec0d38840124c21f759888cae43c33540c9851 (patch) | |
tree | e2296492ba31c9438e1d61b34a1e5164943a2569 /OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |
parent | avoid a null ref (diff) | |
download | opensim-SC-57ec0d38840124c21f759888cae43c33540c9851.zip opensim-SC-57ec0d38840124c21f759888cae43c33540c9851.tar.gz opensim-SC-57ec0d38840124c21f759888cae43c33540c9851.tar.bz2 opensim-SC-57ec0d38840124c21f759888cae43c33540c9851.tar.xz |
change caps get mesh and texture throttle
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 86 |
1 files changed, 11 insertions, 75 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 7d1a380..0588648 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -113,7 +113,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
113 | { | 113 | { |
114 | s.EventManager.OnRegisterCaps -= RegisterCaps; | 114 | s.EventManager.OnRegisterCaps -= RegisterCaps; |
115 | s.EventManager.OnDeregisterCaps -= DeregisterCaps; | 115 | s.EventManager.OnDeregisterCaps -= DeregisterCaps; |
116 | s.EventManager.OnThrottleUpdate -= ThrottleUpdate; | ||
117 | m_NumberScenes--; | 116 | m_NumberScenes--; |
118 | m_scene = null; | 117 | m_scene = null; |
119 | } | 118 | } |
@@ -129,7 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
129 | 128 | ||
130 | s.EventManager.OnRegisterCaps += RegisterCaps; | 129 | s.EventManager.OnRegisterCaps += RegisterCaps; |
131 | s.EventManager.OnDeregisterCaps += DeregisterCaps; | 130 | s.EventManager.OnDeregisterCaps += DeregisterCaps; |
132 | s.EventManager.OnThrottleUpdate += ThrottleUpdate; | ||
133 | 131 | ||
134 | m_NumberScenes++; | 132 | m_NumberScenes++; |
135 | 133 | ||
@@ -149,19 +147,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
149 | } | 147 | } |
150 | } | 148 | } |
151 | } | 149 | } |
152 | |||
153 | // 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. | ||
154 | public void ThrottleUpdate(ScenePresence p) | ||
155 | { | ||
156 | byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); | ||
157 | UUID user = p.UUID; | ||
158 | int imagethrottle = p.ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Texture); | ||
159 | PollServiceTextureEventArgs args; | ||
160 | if (m_pollservices.TryGetValue(user,out args)) | ||
161 | { | ||
162 | args.UpdateThrottle(imagethrottle); | ||
163 | } | ||
164 | } | ||
165 | 150 | ||
166 | public void PostInitialise() | 151 | public void PostInitialise() |
167 | { | 152 | { |
@@ -198,20 +183,27 @@ namespace OpenSim.Region.ClientStack.Linden | |||
198 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); | 183 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); |
199 | 184 | ||
200 | private Scene m_scene; | 185 | private Scene m_scene; |
201 | private CapsDataThrottler m_throttler; | 186 | private ScenePresence m_presence; |
202 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : | 187 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : |
203 | base(null, "", null, null, null, null, pId, int.MaxValue) | 188 | base(null, "", null, null, null, null, pId, int.MaxValue) |
204 | { | 189 | { |
205 | m_scene = scene; | 190 | m_scene = scene; |
206 | m_throttler = new CapsDataThrottler(100000); | ||
207 | // x is request id, y is userid | 191 | // x is request id, y is userid |
208 | HasEvents = (x, y) => | 192 | HasEvents = (x, y) => |
209 | { | 193 | { |
210 | lock (responses) | 194 | lock (responses) |
211 | { | 195 | { |
212 | bool ret = m_throttler.hasEvents(x, responses); | 196 | APollResponse response; |
213 | return ret; | 197 | if (responses.TryGetValue(x, out response)) |
198 | { | ||
199 | if (m_presence == null) | ||
200 | m_presence = m_scene.GetScenePresence(pId); | ||
214 | 201 | ||
202 | if (m_presence == null || m_presence.IsDeleted) | ||
203 | return true; | ||
204 | return m_presence.CapCanSendAsset(0, response.bytes); | ||
205 | } | ||
206 | return false; | ||
215 | } | 207 | } |
216 | }; | 208 | }; |
217 | 209 | ||
@@ -235,7 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
235 | finally | 227 | finally |
236 | { | 228 | { |
237 | responses.Remove(x); | 229 | responses.Remove(x); |
238 | m_throttler.PassTime(); | ||
239 | } | 230 | } |
240 | } | 231 | } |
241 | }; | 232 | }; |
@@ -260,7 +251,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
260 | } | 251 | } |
261 | } | 252 | } |
262 | m_queue.Add(reqinfo); | 253 | m_queue.Add(reqinfo); |
263 | m_throttler.PassTime(); | ||
264 | }; | 254 | }; |
265 | 255 | ||
266 | // this should never happen except possible on shutdown | 256 | // this should never happen except possible on shutdown |
@@ -346,7 +336,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
346 | if(dropedResponses.Contains(requestID)) | 336 | if(dropedResponses.Contains(requestID)) |
347 | { | 337 | { |
348 | dropedResponses.Remove(requestID); | 338 | dropedResponses.Remove(requestID); |
349 | m_throttler.PassTime(); | ||
350 | return; | 339 | return; |
351 | } | 340 | } |
352 | } | 341 | } |
@@ -356,15 +345,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
356 | response = response | 345 | response = response |
357 | }; | 346 | }; |
358 | } | 347 | } |
359 | m_throttler.PassTime(); | ||
360 | } | ||
361 | |||
362 | internal void UpdateThrottle(int pimagethrottle) | ||
363 | { | ||
364 | int tmp = 2 * pimagethrottle; | ||
365 | if(tmp < 10000) | ||
366 | tmp = 10000; | ||
367 | m_throttler.ThrottleBytes = tmp; | ||
368 | } | 348 | } |
369 | } | 349 | } |
370 | 350 | ||
@@ -437,49 +417,5 @@ namespace OpenSim.Region.ClientStack.Linden | |||
437 | poolreq.thepoll.Process(poolreq); | 417 | poolreq.thepoll.Process(poolreq); |
438 | } | 418 | } |
439 | } | 419 | } |
440 | |||
441 | internal sealed class CapsDataThrottler | ||
442 | { | ||
443 | private double lastTimeElapsed = 0; | ||
444 | private volatile int BytesSent = 0; | ||
445 | public CapsDataThrottler(int pBytes) | ||
446 | { | ||
447 | if(pBytes < 10000) | ||
448 | pBytes = 10000; | ||
449 | ThrottleBytes = pBytes; | ||
450 | lastTimeElapsed = Util.GetTimeStamp(); | ||
451 | } | ||
452 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.APollResponse> responses) | ||
453 | { | ||
454 | PassTime(); | ||
455 | // Note, this is called IN LOCK | ||
456 | GetTextureModule.APollResponse response; | ||
457 | if (responses.TryGetValue(key, out response)) | ||
458 | { | ||
459 | if (response.bytes == 0 || BytesSent <= ThrottleBytes) | ||
460 | { | ||
461 | BytesSent += response.bytes; | ||
462 | return true; | ||
463 | } | ||
464 | } | ||
465 | return false; | ||
466 | } | ||
467 | |||
468 | public void PassTime() | ||
469 | { | ||
470 | double currenttime = Util.GetTimeStamp(); | ||
471 | double timeElapsed = currenttime - lastTimeElapsed; | ||
472 | if(timeElapsed < .05) | ||
473 | return; | ||
474 | int add = (int)(ThrottleBytes * timeElapsed); | ||
475 | if (add >= 1000) | ||
476 | { | ||
477 | lastTimeElapsed = currenttime; | ||
478 | BytesSent -= add; | ||
479 | if (BytesSent < 0) BytesSent = 0; | ||
480 | } | ||
481 | } | ||
482 | public int ThrottleBytes; | ||
483 | } | ||
484 | } | 420 | } |
485 | } | 421 | } |