diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 8bd3461..2aeb4cc 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> |
@@ -178,21 +176,7 @@ namespace OpenMetaverse | |||
178 | { | 176 | { |
179 | if (!UsePools) | 177 | if (!UsePools) |
180 | { | 178 | { |
181 | m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | 179 | 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 | 180 | ||
197 | UsePools = true; | 181 | UsePools = true; |
198 | 182 | ||
@@ -207,7 +191,6 @@ namespace OpenMetaverse | |||
207 | if (UsePools) | 191 | if (UsePools) |
208 | { | 192 | { |
209 | UsePools = false; | 193 | UsePools = false; |
210 | StatsManager.DeregisterStat(m_poolCountStat); | ||
211 | 194 | ||
212 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | 195 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. |
213 | 196 | ||
@@ -222,7 +205,7 @@ namespace OpenMetaverse | |||
222 | UDPPacketBuffer buf; | 205 | UDPPacketBuffer buf; |
223 | 206 | ||
224 | if (UsePools) | 207 | if (UsePools) |
225 | buf = m_pool.GetObject(); | 208 | buf = Pool.GetObject(); |
226 | else | 209 | else |
227 | buf = new UDPPacketBuffer(); | 210 | buf = new UDPPacketBuffer(); |
228 | 211 | ||
@@ -305,7 +288,7 @@ namespace OpenMetaverse | |||
305 | finally | 288 | finally |
306 | { | 289 | { |
307 | if (UsePools) | 290 | if (UsePools) |
308 | m_pool.ReturnObject(buffer); | 291 | Pool.ReturnObject(buffer); |
309 | 292 | ||
310 | // Synchronous mode waits until the packet callback completes | 293 | // Synchronous mode waits until the packet callback completes |
311 | // before starting the receive to fetch another packet | 294 | // before starting the receive to fetch another packet |
@@ -347,4 +330,4 @@ namespace OpenMetaverse | |||
347 | catch (ObjectDisposedException) { } | 330 | catch (ObjectDisposedException) { } |
348 | } | 331 | } |
349 | } | 332 | } |
350 | } | 333 | } \ No newline at end of file |