aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-01-22 00:24:29 +0000
committerUbitUmarov2018-01-22 00:24:29 +0000
commit73b587989cf64bee78d3a5a62e96cb4646d71970 (patch)
treeb184cf93db7b9b9d42e73701602ff3f085149abd /OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
parentgive BlockingCollection another chance (diff)
downloadopensim-SC-73b587989cf64bee78d3a5a62e96cb4646d71970.zip
opensim-SC-73b587989cf64bee78d3a5a62e96cb4646d71970.tar.gz
opensim-SC-73b587989cf64bee78d3a5a62e96cb4646d71970.tar.bz2
opensim-SC-73b587989cf64bee78d3a5a62e96cb4646d71970.tar.xz
give BlockingCollection more chances
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs86
1 files changed, 43 insertions, 43 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index 87ded7b..5be75fa 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -28,17 +28,14 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Collections.Specialized; 31using System.Collections.Concurrent;
32using System.Reflection; 32using System.Reflection;
33using System.IO;
34using System.Threading; 33using System.Threading;
35using System.Web;
36using Mono.Addins; 34using Mono.Addins;
37using OpenSim.Framework.Monitoring; 35using OpenSim.Framework.Monitoring;
38using log4net; 36using log4net;
39using Nini.Config; 37using Nini.Config;
40using OpenMetaverse; 38using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42using OpenSim.Capabilities.Handlers; 39using OpenSim.Capabilities.Handlers;
43using OpenSim.Framework; 40using OpenSim.Framework;
44using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
@@ -57,7 +54,6 @@ namespace OpenSim.Region.ClientStack.Linden
57// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 55
59 private Scene m_scene; 56 private Scene m_scene;
60 private IAssetService m_AssetService;
61 private bool m_Enabled = true; 57 private bool m_Enabled = true;
62 private string m_URL; 58 private string m_URL;
63 59
@@ -65,20 +61,19 @@ namespace OpenSim.Region.ClientStack.Linden
65 private string m_RedirectURL = null; 61 private string m_RedirectURL = null;
66 private string m_RedirectURL2 = null; 62 private string m_RedirectURL2 = null;
67 63
68 struct aPollRequest 64 class APollRequest
69 { 65 {
70 public PollServiceMeshEventArgs thepoll; 66 public PollServiceMeshEventArgs thepoll;
71 public UUID reqID; 67 public UUID reqID;
72 public Hashtable request; 68 public Hashtable request;
73 } 69 }
74 70
75 public class aPollResponse 71 public class APollResponse
76 { 72 {
77 public Hashtable response; 73 public Hashtable response;
78 public int bytes; 74 public int bytes;
79 } 75 }
80 76
81
82 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
83 78
84 private static GetMeshHandler m_getMeshHandler; 79 private static GetMeshHandler m_getMeshHandler;
@@ -88,8 +83,7 @@ namespace OpenSim.Region.ClientStack.Linden
88 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 83 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
89 private static Thread[] m_workerThreads = null; 84 private static Thread[] m_workerThreads = null;
90 private static int m_NumberScenes = 0; 85 private static int m_NumberScenes = 0;
91 private static OpenSim.Framework.BlockingQueue<aPollRequest> m_queue = 86 private static BlockingCollection<APollRequest> m_queue = new BlockingCollection<APollRequest>();
92 new OpenSim.Framework.BlockingQueue<aPollRequest>();
93 87
94 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>(); 88 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>();
95 89
@@ -131,33 +125,35 @@ namespace OpenSim.Region.ClientStack.Linden
131 return; 125 return;
132 126
133 m_scene = pScene; 127 m_scene = pScene;
134
135 m_assetService = pScene.AssetService;
136 } 128 }
137 129
138 public void RemoveRegion(Scene scene) 130 public void RemoveRegion(Scene s)
139 { 131 {
140 if (!m_Enabled) 132 if (!m_Enabled)
141 return; 133 return;
142 134
143 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 135 s.EventManager.OnRegisterCaps -= RegisterCaps;
144 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; 136 s.EventManager.OnDeregisterCaps -= DeregisterCaps;
145 m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; 137 s.EventManager.OnThrottleUpdate -= ThrottleUpdate;
146 m_NumberScenes--; 138 m_NumberScenes--;
147 m_scene = null; 139 m_scene = null;
148 } 140 }
149 141
150 public void RegionLoaded(Scene scene) 142 public void RegionLoaded(Scene s)
151 { 143 {
152 if (!m_Enabled) 144 if (!m_Enabled)
153 return; 145 return;
154 146
155 m_AssetService = m_scene.RequestModuleInterface<IAssetService>(); 147 if(m_assetService == null)
156 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 148 {
157 // We'll reuse the same handler for all requests. 149 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
158 m_getMeshHandler = new GetMeshHandler(m_assetService); 150 // We'll reuse the same handler for all requests.
159 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; 151 m_getMeshHandler = new GetMeshHandler(m_assetService);
160 m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; 152 }
153
154 s.EventManager.OnRegisterCaps += RegisterCaps;
155 s.EventManager.OnDeregisterCaps += DeregisterCaps;
156 s.EventManager.OnThrottleUpdate += ThrottleUpdate;
161 157
162 m_NumberScenes++; 158 m_NumberScenes++;
163 159
@@ -189,7 +185,7 @@ namespace OpenSim.Region.ClientStack.Linden
189 // Prevent red ink. 185 // Prevent red ink.
190 try 186 try
191 { 187 {
192 m_queue.Clear(); 188 m_queue.Dispose();
193 } 189 }
194 catch {} 190 catch {}
195 } 191 }
@@ -201,14 +197,18 @@ namespace OpenSim.Region.ClientStack.Linden
201 197
202 private static void DoMeshRequests() 198 private static void DoMeshRequests()
203 { 199 {
204 while(true) 200 while (m_NumberScenes > 0)
205 { 201 {
206 aPollRequest poolreq = m_queue.Dequeue(4500); 202 APollRequest poolreq;
207 Watchdog.UpdateThread(); 203 if(m_queue.TryTake(out poolreq, 4500))
208 if(m_NumberScenes <= 0) 204 {
209 return; 205 if(m_NumberScenes <= 0)
210 if(poolreq.reqID != UUID.Zero) 206 break;
211 poolreq.thepoll.Process(poolreq); 207
208 if(poolreq.reqID != UUID.Zero)
209 poolreq.thepoll.Process(poolreq);
210 }
211 Watchdog.UpdateThread();
212 } 212 }
213 } 213 }
214 214
@@ -228,8 +228,8 @@ namespace OpenSim.Region.ClientStack.Linden
228 { 228 {
229 private List<Hashtable> requests = 229 private List<Hashtable> requests =
230 new List<Hashtable>(); 230 new List<Hashtable>();
231 private Dictionary<UUID, aPollResponse> responses = 231 private Dictionary<UUID, APollResponse> responses =
232 new Dictionary<UUID, aPollResponse>(); 232 new Dictionary<UUID, APollResponse>();
233 private HashSet<UUID> dropedResponses = new HashSet<UUID>(); 233 private HashSet<UUID> dropedResponses = new HashSet<UUID>();
234 234
235 private Scene m_scene; 235 private Scene m_scene;
@@ -278,12 +278,12 @@ namespace OpenSim.Region.ClientStack.Linden
278 // x is request id, y is request data hashtable 278 // x is request id, y is request data hashtable
279 Request = (x, y) => 279 Request = (x, y) =>
280 { 280 {
281 aPollRequest reqinfo = new aPollRequest(); 281 APollRequest reqinfo = new APollRequest();
282 reqinfo.thepoll = this; 282 reqinfo.thepoll = this;
283 reqinfo.reqID = x; 283 reqinfo.reqID = x;
284 reqinfo.request = y; 284 reqinfo.request = y;
285 285
286 m_queue.Enqueue(reqinfo); 286 m_queue.Add(reqinfo);
287 m_throttler.PassTime(); 287 m_throttler.PassTime();
288 }; 288 };
289 289
@@ -309,7 +309,7 @@ namespace OpenSim.Region.ClientStack.Linden
309 }; 309 };
310 } 310 }
311 311
312 public void Process(aPollRequest requestinfo) 312 public void Process(APollRequest requestinfo)
313 { 313 {
314 Hashtable response; 314 Hashtable response;
315 315
@@ -338,7 +338,7 @@ namespace OpenSim.Region.ClientStack.Linden
338 response["str_response_string"] = "Script timeout"; 338 response["str_response_string"] = "Script timeout";
339 response["content_type"] = "text/plain"; 339 response["content_type"] = "text/plain";
340 response["keepalive"] = false; 340 response["keepalive"] = false;
341 responses[requestID] = new aPollResponse() { bytes = 0, response = response}; 341 responses[requestID] = new APollResponse() { bytes = 0, response = response};
342 342
343 return; 343 return;
344 } 344 }
@@ -357,7 +357,7 @@ namespace OpenSim.Region.ClientStack.Linden
357 } 357 }
358 } 358 }
359 359
360 responses[requestID] = new aPollResponse() 360 responses[requestID] = new APollResponse()
361 { 361 {
362 bytes = (int)response["int_bytes"], 362 bytes = (int)response["int_bytes"],
363 response = response 363 response = response
@@ -437,7 +437,7 @@ namespace OpenSim.Region.ClientStack.Linden
437 lastTimeElapsed = Util.GetTimeStampMS(); 437 lastTimeElapsed = Util.GetTimeStampMS();
438 } 438 }
439 439
440 public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) 440 public bool hasEvents(UUID key, Dictionary<UUID, APollResponse> responses)
441 { 441 {
442 PassTime(); 442 PassTime();
443 // Note, this is called IN LOCK 443 // Note, this is called IN LOCK
@@ -447,7 +447,7 @@ namespace OpenSim.Region.ClientStack.Linden
447 { 447 {
448 return false; 448 return false;
449 } 449 }
450 aPollResponse response; 450 APollResponse response;
451 if (responses.TryGetValue(key, out response)) 451 if (responses.TryGetValue(key, out response))
452 { 452 {
453 // Normal 453 // Normal
@@ -472,7 +472,7 @@ namespace OpenSim.Region.ClientStack.Linden
472 return; 472 return;
473 int add = (int)(ThrottleBytes * timeElapsed * 0.001); 473 int add = (int)(ThrottleBytes * timeElapsed * 0.001);
474 if (add >= 1000) 474 if (add >= 1000)
475 { 475 {
476 lastTimeElapsed = currenttime; 476 lastTimeElapsed = currenttime;
477 BytesSent -= add; 477 BytesSent -= add;
478 if (BytesSent < 0) BytesSent = 0; 478 if (BytesSent < 0) BytesSent = 0;
@@ -480,6 +480,6 @@ namespace OpenSim.Region.ClientStack.Linden
480 } 480 }
481 481
482 public int ThrottleBytes; 482 public int ThrottleBytes;
483 } 483 }
484 } 484 }
485} 485}