Author: toad
Date: 2005-11-25 17:10:27 +0000 (Fri, 25 Nov 2005)
New Revision: 7601

Modified:
   trunk/freenet/src/freenet/client/RetryTracker.java
   trunk/freenet/src/freenet/client/Segment.java
   trunk/freenet/src/freenet/node/RequestThrottle.java
   trunk/freenet/src/freenet/node/Version.java
Log:
220 (mandatory):
Fix deadlock on fetch reported by sleon.
Make request throttle more sensitive.

Modified: trunk/freenet/src/freenet/client/RetryTracker.java
===================================================================
--- trunk/freenet/src/freenet/client/RetryTracker.java  2005-11-25 16:45:05 UTC 
(rev 7600)
+++ trunk/freenet/src/freenet/client/RetryTracker.java  2005-11-25 17:10:27 UTC 
(rev 7601)
@@ -173,22 +173,24 @@
         * Move it out of the running list and back into the relevant list, 
unless
         * we have run out of retries.
         */
-       public synchronized void nonfatalError(SplitfileBlock block, int 
reasonCode) {
+       public void nonfatalError(SplitfileBlock block, int reasonCode) {
                if(callOnProgress)
                        callback.onProgress();
-               nonfatalErrors.inc(reasonCode);
-               runningBlocks.remove(block);
-               int levelNumber = block.getRetryCount();
-               levelNumber++;
-               Logger.minor(this, "Non-fatal error on "+block+" -> 
"+levelNumber);
-               if(levelNumber > maxLevel) {
-                       failedBlocksTooManyRetries.add(block);
-                       Logger.minor(this, "Finished with "+block);
-               } else {
-                       Level newLevel = makeLevel(levelNumber);
-                       newLevel.add(block);
+               synchronized(this) {
+                       nonfatalErrors.inc(reasonCode);
+                       runningBlocks.remove(block);
+                       int levelNumber = block.getRetryCount();
+                       levelNumber++;
+                       Logger.minor(this, "Non-fatal error on "+block+" -> 
"+levelNumber);
+                       if(levelNumber > maxLevel) {
+                               failedBlocksTooManyRetries.add(block);
+                               Logger.minor(this, "Finished with "+block);
+                       } else {
+                               Level newLevel = makeLevel(levelNumber);
+                               newLevel.add(block);
+                       }
+                       maybeStart(false);
                }
-               maybeStart(false);
        }

        /**
@@ -196,13 +198,15 @@
         * Move it into the fatal error list.
         * @param reasonCode A client-specific code indicating the type of 
failure.
         */
-       public synchronized void fatalError(SplitfileBlock block, int 
reasonCode) {
+       public void fatalError(SplitfileBlock block, int reasonCode) {
                if(callOnProgress)
                        callback.onProgress();
-               fatalErrors.inc(reasonCode);
-               runningBlocks.remove(block);
-               failedBlocksFatalErrors.add(block);
-               maybeStart(false);
+               synchronized(this) {
+                       fatalErrors.inc(reasonCode);
+                       runningBlocks.remove(block);
+                       failedBlocksFatalErrors.add(block);
+                       maybeStart(false);
+               }
        }

        /**
@@ -248,13 +252,15 @@
                }
        }

-       public synchronized void success(SplitfileBlock block) {
+       public void success(SplitfileBlock block) {
                if(callOnProgress)
                        callback.onProgress();
-               if(killed) return;
-               runningBlocks.remove(block);
-               succeededBlocks.add(block);
-               maybeStart(false);
+               synchronized(this) {
+                       if(killed) return;
+                       runningBlocks.remove(block);
+                       succeededBlocks.add(block);
+                       maybeStart(false);
+               }
        }

        public synchronized void callOnProgress() {
@@ -320,6 +326,10 @@
                        succeededBlocks.toArray(new 
SplitfileBlock[succeededBlocks.size()]);
        }

+       public synchronized int succeededBlocksLength() {
+               return succeededBlocks.size();
+       }
+       
        /**
         * Count the number of blocks which could not be fetched because we ran 
out
         * of retries.

Modified: trunk/freenet/src/freenet/client/Segment.java
===================================================================
--- trunk/freenet/src/freenet/client/Segment.java       2005-11-25 16:45:05 UTC 
(rev 7600)
+++ trunk/freenet/src/freenet/client/Segment.java       2005-11-25 17:10:27 UTC 
(rev 7601)
@@ -256,7 +256,7 @@
        }

        public int fetchedBlocks() {
-               return tracker.succeededBlocks().length;
+               return tracker.succeededBlocksLength();
        }

        public int failedBlocks() {

Modified: trunk/freenet/src/freenet/node/RequestThrottle.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestThrottle.java 2005-11-25 16:45:05 UTC 
(rev 7600)
+++ trunk/freenet/src/freenet/node/RequestThrottle.java 2005-11-25 17:10:27 UTC 
(rev 7601)
@@ -7,7 +7,7 @@
  */
 public class RequestThrottle {

-       protected static final float PACKET_DROP_DECREASE_MULTIPLE = 0.97f;
+       protected static final float PACKET_DROP_DECREASE_MULTIPLE = 0.875f;
        protected static final float PACKET_TRANSMIT_INCREMENT = (4 * (1 - 
(PACKET_DROP_DECREASE_MULTIPLE * PACKET_DROP_DECREASE_MULTIPLE))) / 3;
        protected static final long MAX_DELAY = 5*60*1000;
        protected static final long MIN_DELAY = 20;

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2005-11-25 16:45:05 UTC (rev 
7600)
+++ trunk/freenet/src/freenet/node/Version.java 2005-11-25 17:10:27 UTC (rev 
7601)
@@ -20,10 +20,10 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       public static final int buildNumber = 219;
+       public static final int buildNumber = 220;

        /** Oldest build of Fred we will talk to */
-       public static final int lastGoodBuild = 219;
+       public static final int lastGoodBuild = 220;

        /** The highest reported build of fred */
        public static int highestSeenBuild = buildNumber;


Reply via email to