aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-10-23 02:44:15 +0100
committerJustin Clark-Casey (justincc)2012-10-23 02:44:15 +0100
commit319ebaca06db3d4a38beff74725d321b7c836157 (patch)
treea75a30d49042353bc963c5c7ccbf11b3e7b7020d /OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
parentAdd object count stats for new IncomingPacket and UDPPacketBuffer pools if th... (diff)
downloadopensim-SC_OLD-319ebaca06db3d4a38beff74725d321b7c836157.zip
opensim-SC_OLD-319ebaca06db3d4a38beff74725d321b7c836157.tar.gz
opensim-SC_OLD-319ebaca06db3d4a38beff74725d321b7c836157.tar.bz2
opensim-SC_OLD-319ebaca06db3d4a38beff74725d321b7c836157.tar.xz
Make it possible to turn the base UDP object packet pools on and off whilst running via the "debug lludp pool <on|off>" console command. For debug purposes.
This does not currently apply to the higher LLUDP packetpool.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs66
1 files changed, 45 insertions, 21 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index 18abfd6..85cbb06 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -77,6 +77,8 @@ 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
80 /// <summary> 82 /// <summary>
81 /// Default constructor 83 /// Default constructor
82 /// </summary> 84 /// </summary>
@@ -107,27 +109,6 @@ namespace OpenMetaverse
107 /// necessary</remarks> 109 /// necessary</remarks>
108 public void StartInbound(int recvBufferSize, bool asyncPacketHandling) 110 public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
109 { 111 {
110 if (UsePools)
111 {
112 m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
113
114 StatsManager.RegisterStat(
115 new Stat(
116 "UDPPacketBufferPoolCount",
117 "Objects within the UDPPacketBuffer pool",
118 "The number of objects currently stored within the UDPPacketBuffer pool",
119 "",
120 "clientstack",
121 "packetpool",
122 StatType.Pull,
123 stat => stat.Value = m_pool.Count,
124 StatVerbosity.Debug));
125 }
126 else
127 {
128 m_pool = null;
129 }
130
131 m_asyncPacketHandling = asyncPacketHandling; 112 m_asyncPacketHandling = asyncPacketHandling;
132 113
133 if (!IsRunningInbound) 114 if (!IsRunningInbound)
@@ -197,6 +178,49 @@ namespace OpenMetaverse
197 IsRunningOutbound = false; 178 IsRunningOutbound = false;
198 } 179 }
199 180
181 protected virtual bool EnablePools()
182 {
183 if (!UsePools)
184 {
185 m_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
201 UsePools = true;
202
203 return true;
204 }
205
206 return false;
207 }
208
209 protected virtual bool DisablePools()
210 {
211 if (UsePools)
212 {
213 UsePools = false;
214 StatsManager.DeregisterStat(m_poolCountStat);
215
216 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
217
218 return true;
219 }
220
221 return false;
222 }
223
200 private void AsyncBeginReceive() 224 private void AsyncBeginReceive()
201 { 225 {
202 UDPPacketBuffer buf; 226 UDPPacketBuffer buf;