aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs89
1 files changed, 86 insertions, 3 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index df4bbb3..b8951d9 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -173,6 +173,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
173 private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); 173 private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
174 private Pool<IncomingPacket> m_incomingPacketPool; 174 private Pool<IncomingPacket> m_incomingPacketPool;
175 175
176 private Stat m_incomingPacketPoolStat;
177
176 private int m_defaultRTO = 0; 178 private int m_defaultRTO = 0;
177 private int m_maxRTO = 0; 179 private int m_maxRTO = 0;
178 private int m_ackTimeout = 0; 180 private int m_ackTimeout = 0;
@@ -217,6 +219,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
217 219
218 m_circuitManager = circuitManager; 220 m_circuitManager = circuitManager;
219 int sceneThrottleBps = 0; 221 int sceneThrottleBps = 0;
222 bool usePools = false;
220 223
221 IConfig config = configSource.Configs["ClientStack.LindenUDP"]; 224 IConfig config = configSource.Configs["ClientStack.LindenUDP"];
222 if (config != null) 225 if (config != null)
@@ -249,7 +252,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
249 { 252 {
250 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 253 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
251 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 254 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
252 UsePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", false); 255 usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools);
253 } 256 }
254 257
255 #region BinaryStats 258 #region BinaryStats
@@ -280,8 +283,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
280 m_throttle = new TokenBucket(null, sceneThrottleBps); 283 m_throttle = new TokenBucket(null, sceneThrottleBps);
281 ThrottleRates = new ThrottleRates(configSource); 284 ThrottleRates = new ThrottleRates(configSource);
282 285
283 if (UsePools) 286 if (usePools)
284 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); 287 EnablePools();
285 } 288 }
286 289
287 public void Start() 290 public void Start()
@@ -334,6 +337,50 @@ namespace OpenSim.Region.ClientStack.LindenUDP
334 base.StopInbound(); 337 base.StopInbound();
335 } 338 }
336 339
340 protected override bool EnablePools()
341 {
342 if (!UsePools)
343 {
344 base.EnablePools();
345
346 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
347
348 m_incomingPacketPoolStat
349 = new Stat(
350 "IncomingPacketPoolCount",
351 "Objects within incoming packet pool",
352 "The number of objects currently stored within the incoming packet pool",
353 "",
354 "clientstack",
355 "packetpool",
356 StatType.Pull,
357 stat => stat.Value = m_incomingPacketPool.Count,
358 StatVerbosity.Debug);
359
360 StatsManager.RegisterStat(m_incomingPacketPoolStat);
361
362 return true;
363 }
364
365 return false;
366 }
367
368 protected override bool DisablePools()
369 {
370 if (UsePools)
371 {
372 base.DisablePools();
373
374 StatsManager.DeregisterStat(m_incomingPacketPoolStat);
375
376 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
377
378 return true;
379 }
380
381 return false;
382 }
383
337 /// <summary> 384 /// <summary>
338 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. 385 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
339 /// </summary> 386 /// </summary>
@@ -400,6 +447,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
400 MainConsole.Instance.Commands.AddCommand( 447 MainConsole.Instance.Commands.AddCommand(
401 "Debug", 448 "Debug",
402 false, 449 false,
450 "debug lludp pool",
451 "debug lludp pool <on|off>",
452 "Turn object pooling within the lludp component on or off.",
453 HandlePoolCommand);
454
455 MainConsole.Instance.Commands.AddCommand(
456 "Debug",
457 false,
403 "debug lludp status", 458 "debug lludp status",
404 "debug lludp status", 459 "debug lludp status",
405 "Return status of LLUDP packet processing.", 460 "Return status of LLUDP packet processing.",
@@ -440,6 +495,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
440 StopOutbound(); 495 StopOutbound();
441 } 496 }
442 497
498 private void HandlePoolCommand(string module, string[] args)
499 {
500 if (args.Length != 4)
501 {
502 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
503 return;
504 }
505
506 string enabled = args[3];
507
508 if (enabled == "on")
509 {
510 if (EnablePools())
511 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name);
512 }
513 else if (enabled == "off")
514 {
515 if (DisablePools())
516 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name);
517 }
518 else
519 {
520 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
521 }
522 }
523
443 private void HandleStatusCommand(string module, string[] args) 524 private void HandleStatusCommand(string module, string[] args)
444 { 525 {
445 MainConsole.Instance.OutputFormat( 526 MainConsole.Instance.OutputFormat(
@@ -447,6 +528,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
447 528
448 MainConsole.Instance.OutputFormat( 529 MainConsole.Instance.OutputFormat(
449 "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled"); 530 "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
531
532 MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off");
450 } 533 }
451 534
452 public bool HandlesRegion(Location x) 535 public bool HandlesRegion(Location x)