Author: toad
Date: 2008-04-10 18:31:03 +0000 (Thu, 10 Apr 2008)
New Revision: 19151

Modified:
   trunk/freenet/src/freenet/node/NodeStats.java
Log:
Output bandwidth liability: refuse to accept that less than 20% of our overall 
limit is available for requests. Always accept some requests even if our 
overhead has averaged over the limit for a while.

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java       2008-04-10 18:27:11 UTC 
(rev 19150)
+++ trunk/freenet/src/freenet/node/NodeStats.java       2008-04-10 18:31:03 UTC 
(rev 19151)
@@ -487,8 +487,19 @@
                        successfulSskInsertBytesSentAverage.currentValue() * 
numSSKInserts +
                        successfulChkOfferReplyBytesSentAverage.currentValue() 
* numCHKOfferReplies +
                        successfulSskOfferReplyBytesSentAverage.currentValue() 
* numSSKOfferReplies;
-               double bandwidthAvailableOutput =
-                       (node.getOutputBandwidthLimit() - 
sentOverheadPerSecond) * 90; // 90 seconds at full power; we have to leave some 
time for the search as well
+               double outputAvailablePerSecond = 
node.getOutputBandwidthLimit() - sentOverheadPerSecond;
+               // If there's been an auto-update, we may have used a vast 
amount of bandwidth for it.
+               // Also, if things have broken, our overhead might be above our 
bandwidth limit,
+               // especially on a slow node.
+               
+               // So impose a minimum of 20% of the bandwidth limit.
+               // This will ensure we don't get stuck in any situation where 
all our bandwidth is overhead,
+               // and we don't accept any requests because of that, so it 
remains that way...
+               outputAvailablePerSecond = Math.max(outputAvailablePerSecond, 
node.getOutputBandwidthLimit() / 5);
+               
+               double bandwidthAvailableOutput = outputAvailablePerSecond * 90;
+               // 90 seconds at full power; we have to leave some time for the 
search as well
+               
                if(bandwidthLiabilityOutput > bandwidthAvailableOutput) {
                        pInstantRejectIncoming.report(1.0);
                        rejected("Output bandwidth liability", isLocal);


Reply via email to