aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs51
1 files changed, 46 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index e7d8a30..8bd3461 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -31,6 +31,7 @@ using System.Net.Sockets;
31using System.Threading; 31using System.Threading;
32using log4net; 32using log4net;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Monitoring;
34 35
35namespace OpenMetaverse 36namespace OpenMetaverse
36{ 37{
@@ -76,6 +77,8 @@ namespace OpenMetaverse
76 /// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks> 77 /// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks>
77 public bool IsRunningOutbound { get; private set; } 78 public bool IsRunningOutbound { get; private set; }
78 79
80 private Stat m_poolCountStat;
81
79 /// <summary> 82 /// <summary>
80 /// Default constructor 83 /// Default constructor
81 /// </summary> 84 /// </summary>
@@ -106,11 +109,6 @@ namespace OpenMetaverse
106 /// necessary</remarks> 109 /// necessary</remarks>
107 public void StartInbound(int recvBufferSize, bool asyncPacketHandling) 110 public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
108 { 111 {
109 if (UsePools)
110 m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
111 else
112 m_pool = null;
113
114 m_asyncPacketHandling = asyncPacketHandling; 112 m_asyncPacketHandling = asyncPacketHandling;
115 113
116 if (!IsRunningInbound) 114 if (!IsRunningInbound)
@@ -176,6 +174,49 @@ namespace OpenMetaverse
176 IsRunningOutbound = false; 174 IsRunningOutbound = false;
177 } 175 }
178 176
177 protected virtual bool EnablePools()
178 {
179 if (!UsePools)
180 {
181 m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
182
183 m_poolCountStat
184 = new Stat(
185 "UDPPacketBufferPoolCount",
186 "Objects within the UDPPacketBuffer pool",
187 "The number of objects currently stored within the UDPPacketBuffer pool",
188 "",
189 "clientstack",
190 "packetpool",
191 StatType.Pull,
192 stat => stat.Value = m_pool.Count,
193 StatVerbosity.Debug);
194
195 StatsManager.RegisterStat(m_poolCountStat);
196
197 UsePools = true;
198
199 return true;
200 }
201
202 return false;
203 }
204
205 protected virtual bool DisablePools()
206 {
207 if (UsePools)
208 {
209 UsePools = false;
210 StatsManager.DeregisterStat(m_poolCountStat);
211
212 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
213
214 return true;
215 }
216
217 return false;
218 }
219
179 private void AsyncBeginReceive() 220 private void AsyncBeginReceive()
180 { 221 {
181 UDPPacketBuffer buf; 222 UDPPacketBuffer buf;