aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs125
1 files changed, 65 insertions, 60 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index b01c7dc..9a561ea 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -146,39 +146,13 @@ namespace OpenSim.Region.ClientStack.Linden
146 } 146 }
147 } 147 }
148 } 148 }
149 private int ExtractImageThrottle(byte[] pthrottles) 149
150 {
151
152 byte[] adjData;
153 int pos = 0;
154
155 if (!BitConverter.IsLittleEndian)
156 {
157 byte[] newData = new byte[7 * 4];
158 Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4);
159
160 for (int i = 0; i < 7; i++)
161 Array.Reverse(newData, i * 4, 4);
162
163 adjData = newData;
164 }
165 else
166 {
167 adjData = pthrottles;
168 }
169
170 pos = pos + 20;
171 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4;
172 //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
173 return texture;
174 }
175
176 // 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. 150 // 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.
177 public void ThrottleUpdate(ScenePresence p) 151 public void ThrottleUpdate(ScenePresence p)
178 { 152 {
179 byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); 153 byte[] throttles = p.ControllingClient.GetThrottlesPacked(1);
180 UUID user = p.UUID; 154 UUID user = p.UUID;
181 int imagethrottle = ExtractImageThrottle(throttles); 155 int imagethrottle = p.ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Texture);
182 PollServiceTextureEventArgs args; 156 PollServiceTextureEventArgs args;
183 if (m_pollservices.TryGetValue(user,out args)) 157 if (m_pollservices.TryGetValue(user,out args))
184 { 158 {
@@ -218,13 +192,15 @@ namespace OpenSim.Region.ClientStack.Linden
218 new List<Hashtable>(); 192 new List<Hashtable>();
219 private Dictionary<UUID, aPollResponse> responses = 193 private Dictionary<UUID, aPollResponse> responses =
220 new Dictionary<UUID, aPollResponse>(); 194 new Dictionary<UUID, aPollResponse>();
195 private HashSet<UUID> dropedResponses = new HashSet<UUID>();
221 196
222 private Scene m_scene; 197 private Scene m_scene;
223 private CapsDataThrottler m_throttler = new CapsDataThrottler(100000); 198 private CapsDataThrottler m_throttler;
224 public PollServiceTextureEventArgs(UUID pId, Scene scene) : 199 public PollServiceTextureEventArgs(UUID pId, Scene scene) :
225 base(null, "", null, null, null, pId, int.MaxValue) 200 base(null, "", null, null, null, null, pId, int.MaxValue)
226 { 201 {
227 m_scene = scene; 202 m_scene = scene;
203 m_throttler = new CapsDataThrottler(100000);
228 // x is request id, y is userid 204 // x is request id, y is userid
229 HasEvents = (x, y) => 205 HasEvents = (x, y) =>
230 { 206 {
@@ -235,6 +211,16 @@ namespace OpenSim.Region.ClientStack.Linden
235 211
236 } 212 }
237 }; 213 };
214
215 Drop = (x, y) =>
216 {
217 lock (responses)
218 {
219 responses.Remove(x);
220 dropedResponses.Add(x);
221 }
222 };
223
238 GetEvents = (x, y) => 224 GetEvents = (x, y) =>
239 { 225 {
240 lock (responses) 226 lock (responses)
@@ -305,53 +291,72 @@ namespace OpenSim.Region.ClientStack.Linden
305 if(m_scene.ShuttingDown) 291 if(m_scene.ShuttingDown)
306 return; 292 return;
307 293
308 if (requestinfo.send503) 294 lock (responses)
309 { 295 {
310 response = new Hashtable(); 296 lock(dropedResponses)
297 {
298 if(dropedResponses.Contains(requestID))
299 {
300 dropedResponses.Remove(requestID);
301 return;
302 }
303 }
311 304
312 response["int_response_code"] = 503; 305 if (requestinfo.send503)
313 response["str_response_string"] = "Throttled"; 306 {
314 response["content_type"] = "text/plain"; 307 response = new Hashtable();
315 response["keepalive"] = false;
316 response["reusecontext"] = false;
317 308
318 Hashtable headers = new Hashtable(); 309 response["int_response_code"] = 503;
319 headers["Retry-After"] = 30; 310 response["str_response_string"] = "Throttled";
320 response["headers"] = headers; 311 response["content_type"] = "text/plain";
312 response["keepalive"] = false;
313 response["reusecontext"] = false;
314
315 Hashtable headers = new Hashtable();
316 headers["Retry-After"] = 30;
317 response["headers"] = headers;
321 318
322 lock (responses)
323 responses[requestID] = new aPollResponse() {bytes = 0, response = response}; 319 responses[requestID] = new aPollResponse() {bytes = 0, response = response};
324 320
325 return; 321 return;
326 } 322 }
327 323
328 // If the avatar is gone, don't bother to get the texture 324 // If the avatar is gone, don't bother to get the texture
329 if (m_scene.GetScenePresence(Id) == null) 325 if (m_scene.GetScenePresence(Id) == null)
330 { 326 {
331 response = new Hashtable(); 327 response = new Hashtable();
332 328
333 response["int_response_code"] = 500; 329 response["int_response_code"] = 500;
334 response["str_response_string"] = "Script timeout"; 330 response["str_response_string"] = "Script timeout";
335 response["content_type"] = "text/plain"; 331 response["content_type"] = "text/plain";
336 response["keepalive"] = false; 332 response["keepalive"] = false;
337 response["reusecontext"] = false; 333 response["reusecontext"] = false;
338 334
339 lock (responses)
340 responses[requestID] = new aPollResponse() {bytes = 0, response = response}; 335 responses[requestID] = new aPollResponse() {bytes = 0, response = response};
341 336
342 return; 337 return;
338 }
343 } 339 }
344 340
345 response = m_getTextureHandler.Handle(requestinfo.request); 341 response = m_getTextureHandler.Handle(requestinfo.request);
342
346 lock (responses) 343 lock (responses)
347 { 344 {
345 lock(dropedResponses)
346 {
347 if(dropedResponses.Contains(requestID))
348 {
349 dropedResponses.Remove(requestID);
350 m_throttler.PassTime();
351 return;
352 }
353 }
348 responses[requestID] = new aPollResponse() 354 responses[requestID] = new aPollResponse()
349 { 355 {
350 bytes = (int) response["int_bytes"], 356 bytes = (int) response["int_bytes"],
351 response = response 357 response = response
352 }; 358 };
353 359 }
354 }
355 m_throttler.PassTime(); 360 m_throttler.PassTime();
356 } 361 }
357 362
@@ -476,7 +481,7 @@ namespace OpenSim.Region.ClientStack.Linden
476 return; 481 return;
477 int add = (int)(ThrottleBytes * timeElapsed * 0.001); 482 int add = (int)(ThrottleBytes * timeElapsed * 0.001);
478 if (add >= 1000) 483 if (add >= 1000)
479 { 484 {
480 lastTimeElapsed = currenttime; 485 lastTimeElapsed = currenttime;
481 BytesSent -= add; 486 BytesSent -= add;
482 if (BytesSent < 0) BytesSent = 0; 487 if (BytesSent < 0) BytesSent = 0;