Author: toad
Date: 2007-04-30 12:53:57 +0000 (Mon, 30 Apr 2007)
New Revision: 13061

Modified:
   trunk/freenet/src/freenet/node/NodeStats.java
Log:
Don't accept an SSK request unless there is space for one of each type of 
request as well as it.
Thanks Anonymous, mrogers.

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java       2007-04-29 22:22:11 UTC 
(rev 13060)
+++ trunk/freenet/src/freenet/node/NodeStats.java       2007-04-30 12:53:57 UTC 
(rev 13061)
@@ -394,11 +394,15 @@
                // Successful cluster timeout protection.
                // Reject request if the result of all our current requests 
completing simultaneously would be that
                // some of them timeout.
+               
+               // Increment each running count unless it is the one we are 
currently processing.
+               // Purpose: Don't allow an SSK request (e.g.) unless there is 
space for a CHK insert *as well*.
+               
                double bandwidthLiabilityOutput =
-                       successfulChkFetchBytesSentAverage.currentValue() * 
node.getNumCHKRequests() +
-                       successfulSskFetchBytesSentAverage.currentValue() * 
node.getNumSSKRequests() +
-                       successfulChkInsertBytesSentAverage.currentValue() * 
node.getNumCHKInserts() +
-                       successfulSskInsertBytesSentAverage.currentValue() * 
node.getNumSSKInserts();
+                       successfulChkFetchBytesSentAverage.currentValue() * 
(node.getNumCHKRequests() + ((!isInsert) && (!isSSK) ? 0 : 1)) +
+                       successfulSskFetchBytesSentAverage.currentValue() * 
(node.getNumSSKRequests() + ((!isInsert) && isSSK ? 0 : 1)) +
+                       successfulChkInsertBytesSentAverage.currentValue() * 
(node.getNumCHKInserts() + (isInsert && (!isSSK) ? 0 : 1)) +
+                       successfulSskInsertBytesSentAverage.currentValue() * 
(node.getNumSSKInserts() + (isInsert && isSSK ? 0 : 1));
                bandwidthLiabilityOutput += getSuccessfulBytes(isSSK, isInsert, 
false).currentValue();
                double bandwidthAvailableOutput =
                        node.getOutputBandwidthLimit() * 90; // 90 seconds at 
full power; we have to leave some time for the search as well


Reply via email to