diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 85cbb06..808d177 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -61,14 +61,14 @@ namespace OpenMetaverse | |||
61 | private bool m_asyncPacketHandling; | 61 | private bool m_asyncPacketHandling; |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Pool to use for handling data. May be null if UsePools = false; | 64 | /// Are we to use object pool(s) to reduce memory churn when receiving data? |
65 | /// </summary> | 65 | /// </summary> |
66 | protected OpenSim.Framework.Pool<UDPPacketBuffer> m_pool; | 66 | public bool UsePools { get; protected set; } |
67 | 67 | ||
68 | /// <summary> | 68 | /// <summary> |
69 | /// Are we to use object pool(s) to reduce memory churn when receiving data? | 69 | /// Pool to use for handling data. May be null if UsePools = false; |
70 | /// </summary> | 70 | /// </summary> |
71 | public bool UsePools { get; protected set; } | 71 | protected OpenSim.Framework.Pool<UDPPacketBuffer> Pool { get; private set; } |
72 | 72 | ||
73 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> | 73 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> |
74 | public bool IsRunningInbound { get; private set; } | 74 | public bool IsRunningInbound { get; private set; } |
@@ -77,8 +77,6 @@ namespace OpenMetaverse | |||
77 | /// <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> |
78 | public bool IsRunningOutbound { get; private set; } | 78 | public bool IsRunningOutbound { get; private set; } |
79 | 79 | ||
80 | private Stat m_poolCountStat; | ||
81 | |||
82 | /// <summary> | 80 | /// <summary> |
83 | /// Default constructor | 81 | /// Default constructor |
84 | /// </summary> | 82 | /// </summary> |
@@ -182,21 +180,7 @@ namespace OpenMetaverse | |||
182 | { | 180 | { |
183 | if (!UsePools) | 181 | if (!UsePools) |
184 | { | 182 | { |
185 | m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | 183 | Pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); |
186 | |||
187 | m_poolCountStat | ||
188 | = new Stat( | ||
189 | "UDPPacketBufferPoolCount", | ||
190 | "Objects within the UDPPacketBuffer pool", | ||
191 | "The number of objects currently stored within the UDPPacketBuffer pool", | ||
192 | "", | ||
193 | "clientstack", | ||
194 | "packetpool", | ||
195 | StatType.Pull, | ||
196 | stat => stat.Value = m_pool.Count, | ||
197 | StatVerbosity.Debug); | ||
198 | |||
199 | StatsManager.RegisterStat(m_poolCountStat); | ||
200 | 184 | ||
201 | UsePools = true; | 185 | UsePools = true; |
202 | 186 | ||
@@ -211,7 +195,6 @@ namespace OpenMetaverse | |||
211 | if (UsePools) | 195 | if (UsePools) |
212 | { | 196 | { |
213 | UsePools = false; | 197 | UsePools = false; |
214 | StatsManager.DeregisterStat(m_poolCountStat); | ||
215 | 198 | ||
216 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | 199 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. |
217 | 200 | ||
@@ -226,7 +209,7 @@ namespace OpenMetaverse | |||
226 | UDPPacketBuffer buf; | 209 | UDPPacketBuffer buf; |
227 | 210 | ||
228 | if (UsePools) | 211 | if (UsePools) |
229 | buf = m_pool.GetObject(); | 212 | buf = Pool.GetObject(); |
230 | else | 213 | else |
231 | buf = new UDPPacketBuffer(); | 214 | buf = new UDPPacketBuffer(); |
232 | 215 | ||
@@ -309,7 +292,7 @@ namespace OpenMetaverse | |||
309 | finally | 292 | finally |
310 | { | 293 | { |
311 | if (UsePools) | 294 | if (UsePools) |
312 | m_pool.ReturnObject(buffer); | 295 | Pool.ReturnObject(buffer); |
313 | 296 | ||
314 | // Synchronous mode waits until the packet callback completes | 297 | // Synchronous mode waits until the packet callback completes |
315 | // before starting the receive to fetch another packet | 298 | // before starting the receive to fetch another packet |