Author: toad
Date: 2006-01-26 19:39:07 +0000 (Thu, 26 Jan 2006)
New Revision: 7937

Modified:
   trunk/freenet/src/freenet/client/InserterContext.java
   trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/Version.java
Log:
389:
More bugfixes.

Modified: trunk/freenet/src/freenet/client/InserterContext.java
===================================================================
--- trunk/freenet/src/freenet/client/InserterContext.java       2006-01-26 
18:28:22 UTC (rev 7936)
+++ trunk/freenet/src/freenet/client/InserterContext.java       2006-01-26 
19:39:07 UTC (rev 7937)
@@ -14,7 +14,7 @@
        public final short splitfileAlgorithm;
        public int maxInsertRetries;
        final int maxSplitInsertThreads;
-       final int consecutiveRNFsCountAsSuccess;
+       public final int consecutiveRNFsCountAsSuccess;
        public final int splitfileSegmentDataBlocks;
        public final int splitfileSegmentCheckBlocks;
        final ClientEventProducer eventProducer;

Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2006-01-26 18:28:22 UTC (rev 7936)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2006-01-26 19:39:07 UTC (rev 7937)
@@ -39,8 +39,10 @@
        final int token; // for e.g. splitfiles
        final boolean isMetadata;
        final int sourceLength;
+       private int consecutiveRNFs;

        public SingleBlockInserter(BaseClientPutter parent, Bucket data, short 
compressionCodec, FreenetURI uri, InserterContext ctx, PutCompletionCallback 
cb, boolean isMetadata, int sourceLength, int token, boolean getCHKOnly) throws 
InserterException {
+               this.consecutiveRNFs = 0;
                this.token = token;
                this.parent = parent;
                this.retries = 0;
@@ -138,6 +140,15 @@
                        Logger.error(this, "Unknown LowLevelPutException code: 
"+e.code);
                        errors.inc(InserterException.INTERNAL_ERROR);
                }
+               if(e.code == LowLevelPutException.ROUTE_NOT_FOUND) {
+                       consecutiveRNFs++;
+                       if(consecutiveRNFs == 
ctx.consecutiveRNFsCountAsSuccess) {
+                               Logger.minor(this, "Consecutive RNFs: 
"+consecutiveRNFs+" - counting as success");
+                               onSuccess();
+                               return;
+                       }
+               } else
+                       consecutiveRNFs = 0;
                Logger.minor(this, "Failed: "+e);
                if(retries > ctx.maxInsertRetries) {
                        if(errors.isOneCodeOnly())
@@ -149,9 +160,11 @@
                parent.scheduler.register(this);
        }

-       private synchronized void fail(InserterException e) {
-               if(finished) return;
-               finished = true;
+       private void fail(InserterException e) {
+               synchronized(this) {
+                       if(finished) return;
+                       finished = true;
+               }
                cb.onFailure(e, this);
        }


Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2006-01-26 18:28:22 UTC (rev 7936)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2006-01-26 19:39:07 UTC (rev 7937)
@@ -50,10 +50,11 @@
        private int fatallyFailedBlocks;
        private int failedBlocks;
        private int fetchedBlocks;
-       private FailureCodeTracker errors;
+       private final FailureCodeTracker errors;

        public SplitFileFetcherSegment(short splitfileType, FreenetURI[] 
splitfileDataBlocks, FreenetURI[] splitfileCheckBlocks, SplitFileFetcher 
fetcher, ArchiveContext archiveContext, FetcherContext fetchContext, long 
maxTempLength, boolean splitUseLengths, int recursionLevel) throws 
MetadataParseException, FetchException {
                this.parentFetcher = fetcher;
+               this.errors = new FailureCodeTracker(false);
                this.archiveContext = archiveContext;
                this.splitfileType = splitfileType;
                dataBlocks = splitfileDataBlocks;
@@ -265,12 +266,13 @@
                                return;
                        }
                        dataBlocks[blockNo] = null;
-               } else if(blockNo < checkBlocks.length) {
-                       if(checkBlocks[blockNo-dataBlocks.length] == null) {
-                               Logger.error(this, "Block already finished: 
"+blockNo);
+               } else if(blockNo < checkBlocks.length + dataBlocks.length) {
+                       blockNo -= dataBlocks.length;
+                       if(checkBlocks[blockNo] == null) {
+                               Logger.error(this, "Check block already 
finished: "+blockNo);
                                return;
                        }
-                       checkBlocks[blockNo-dataBlocks.length] = null;
+                       checkBlocks[blockNo] = null;
                } else
                        Logger.error(this, "Unrecognized block number: 
"+blockNo, new Exception("error"));
                // :(
@@ -283,7 +285,7 @@
                if(e.errorCodes != null)
                        errors.merge(e.errorCodes);
                else
-                       errors.inc(new Integer(e.mode), 
((SingleFileFetcher)state).getRetryCount());
+                       errors.inc(new Integer(e.mode), state == null ? 1 : 
((SingleFileFetcher)state).getRetryCount());
                if(failedBlocks + fatallyFailedBlocks > (dataBlocks.length + 
checkBlocks.length - minFetched)) {
                        fail(new FetchException(FetchException.SPLITFILE_ERROR, 
errors));
                }

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-01-26 18:28:22 UTC (rev 
7936)
+++ trunk/freenet/src/freenet/node/Node.java    2006-01-26 19:39:07 UTC (rev 
7937)
@@ -1397,10 +1397,12 @@
         */
        public DSAPublicKey getKey(byte[] hash) {
                ImmutableByteArrayWrapper w = new 
ImmutableByteArrayWrapper(hash);
+               Logger.minor(this, "Getting "+HexUtil.bytesToHex(hash));
                synchronized(cachedPubKeys) {
                        DSAPublicKey key = (DSAPublicKey) cachedPubKeys.get(w);
                        if(key != null) {
                                cachedPubKeys.push(w, key);
+                               Logger.minor(this, "Got 
"+HexUtil.bytesToHex(hash)+" from cache");
                                return key;
                        }
                }
@@ -1409,6 +1411,7 @@
                        if(key != null) {
                                cacheKey(hash, key);
                        }
+                       Logger.minor(this, "Got "+HexUtil.bytesToHex(hash)+" 
from store");
                        return key;
                } catch (IOException e) {
                        // FIXME deal with disk full, access perms etc; tell 
user about it.

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-01-26 18:28:22 UTC (rev 
7936)
+++ trunk/freenet/src/freenet/node/Version.java 2006-01-26 19:39:07 UTC (rev 
7937)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

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

        /** Oldest build of Fred we will talk to */
        public static final int lastGoodBuild = 386;


Reply via email to