aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs59
1 files changed, 33 insertions, 26 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index e0633d3..ab8d268 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -110,14 +110,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
110 } 110 }
111 111
112 /// <summary> 112 /// <summary>
113 /// The speed limit of this bucket in bytes per second. This is the 113 /// The requested drip rate for this particular bucket.
114 /// number of tokens that are added to the bucket per quantum
115 /// </summary> 114 /// </summary>
116 /// <remarks> 115 /// <remarks>
117 /// RequestedDripRate can never be above MaxDripRate. 116 /// 0 then TotalDripRequest is used instead.
118 /// Tokens are added to the bucket any time 117 /// Can never be above MaxDripRate.
118 /// Tokens are added to the bucket at any time
119 /// <seealso cref="RemoveTokens"/> is called, at the granularity of 119 /// <seealso cref="RemoveTokens"/> is called, at the granularity of
120 /// the system tick interval (typically around 15-22ms)</remarks> 120 /// the system tick interval (typically around 15-22ms)
121 /// FIXME: It is extremely confusing to be able to set a RequestedDripRate of 0 and then receive a positive
122 /// number on get if TotalDripRequest is sent. This also stops us being able to retrieve the fact that
123 /// RequestedDripRate is set to 0. Really, this should always return m_dripRate and then we can get
124 /// (m_dripRate == 0 ? TotalDripRequest : m_dripRate) on some other properties.
125 /// </remarks>
121 protected Int64 m_dripRate; 126 protected Int64 m_dripRate;
122 public virtual Int64 RequestedDripRate 127 public virtual Int64 RequestedDripRate
123 { 128 {
@@ -131,7 +136,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
131 else 136 else
132 m_dripRate = value; 137 m_dripRate = value;
133 138
134 TotalDripRequest = m_dripRate;
135 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst); 139 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
136 140
137 if (Parent != null) 141 if (Parent != null)
@@ -142,15 +146,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
142 /// <summary> 146 /// <summary>
143 /// Gets the drip rate. 147 /// Gets the drip rate.
144 /// </summary> 148 /// </summary>
145 /// <value>DripRate can never be above max.</value> 149 /// <value>
150 /// DripRate can never be above max drip rate or below min drip rate.
151 /// If we are a child bucket then the drip rate return is modifed by the total load on the capacity of the
152 /// parent bucket.
153 /// </value>
146 public virtual Int64 DripRate 154 public virtual Int64 DripRate
147 { 155 {
148 get 156 get
149 { 157 {
158 double rate;
159
160 // FIXME: This doesn't properly work if we have a parent and children and a requested drip rate set
161 // on ourselves which is not equal to the child drip rates.
150 if (Parent == null) 162 if (Parent == null)
151 return Math.Min(RequestedDripRate, TotalDripRequest); 163 {
152 164 if (TotalDripRequest > 0)
153 double rate = (double)RequestedDripRate * Parent.DripRateModifier(); 165 rate = Math.Min(RequestedDripRate, TotalDripRequest);
166 else
167 rate = RequestedDripRate;
168 }
169 else
170 {
171 rate = (double)RequestedDripRate * Parent.DripRateModifier();
172 }
173
154 if (rate < m_minimumDripRate) 174 if (rate < m_minimumDripRate)
155 rate = m_minimumDripRate; 175 rate = m_minimumDripRate;
156 else if (MaxDripRate > 0 && rate > MaxDripRate) 176 else if (MaxDripRate > 0 && rate > MaxDripRate)
@@ -163,18 +183,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
163 // <summary> 183 // <summary>
164 // The maximum rate for flow control. Drip rate can never be greater than this. 184 // The maximum rate for flow control. Drip rate can never be greater than this.
165 // </summary> 185 // </summary>
166// protected Int64 m_maxDripRate;
167// public Int64 MaxDripRate
168// {
169// get { return m_maxDripRate; }
170// //get { return (m_maxDripRate == 0 ? TotalDripRequest : m_maxDripRate); }
171// set { m_maxDripRate = (value == 0 ? 0 : Math.Max(value, m_minimumFlow)); }
172// }
173 public Int64 MaxDripRate { get; set; } 186 public Int64 MaxDripRate { get; set; }
174 187
175 /// <summary> 188 /// <summary>
176 /// The current total of the requested maximum burst rates of 189 /// The current total of the requested maximum burst rates of children buckets.
177 /// this bucket's children buckets.
178 /// </summary> 190 /// </summary>
179 public Int64 TotalDripRequest { get; protected set; } 191 public Int64 TotalDripRequest { get; protected set; }
180 192
@@ -197,8 +209,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
197 Parent = parent; 209 Parent = parent;
198 RequestedDripRate = dripRate; 210 RequestedDripRate = dripRate;
199 MaxDripRate = maxDripRate; 211 MaxDripRate = maxDripRate;
200 // TotalDripRequest = dripRate; // this will be overwritten when a child node registers
201 // MaxBurst = (Int64)((double)dripRate * m_quantumsPerBurst);
202 m_lastDrip = Util.EnvironmentTickCount(); 212 m_lastDrip = Util.EnvironmentTickCount();
203 } 213 }
204 214
@@ -243,7 +253,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
243 lock (m_children) 253 lock (m_children)
244 { 254 {
245 m_children[child] = request; 255 m_children[child] = request;
246 // TotalDripRequest = m_children.Values.Sum();
247 256
248 TotalDripRequest = 0; 257 TotalDripRequest = 0;
249 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children) 258 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children)
@@ -255,12 +264,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
255 { 264 {
256 Int64 effectiveDripRate; 265 Int64 effectiveDripRate;
257 266
258 if (MaxDripRate > 0) 267 if (RequestedDripRate > 0)
259 effectiveDripRate = Math.Min(MaxDripRate, TotalDripRequest); 268 effectiveDripRate = Math.Min(RequestedDripRate, TotalDripRequest);
260 else 269 else
261 effectiveDripRate = TotalDripRequest; 270 effectiveDripRate = TotalDripRequest;
262 271
263 //Parent.RegisterRequest(this, Math.Min(RequestedDripRate, TotalDripRequest));
264 Parent.RegisterRequest(this, effectiveDripRate); 272 Parent.RegisterRequest(this, effectiveDripRate);
265 } 273 }
266 } 274 }
@@ -274,7 +282,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
274 lock (m_children) 282 lock (m_children)
275 { 283 {
276 m_children.Remove(child); 284 m_children.Remove(child);
277 // m_totalDripRequest = m_children.Values.Sum();
278 285
279 TotalDripRequest = 0; 286 TotalDripRequest = 0;
280 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children) 287 foreach (KeyValuePair<TokenBucket, Int64> cref in m_children)