Author: toad
Date: 2006-07-26 19:24:44 +0000 (Wed, 26 Jul 2006)
New Revision: 9780

Modified:
   trunk/freenet/src/freenet/client/async/SingleFileInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
   trunk/freenet/src/freenet/node/Version.java
Log:
907: More insert resuming bugfixes. Might cause some inserts to restart from 
scratch due to prior bugs.

Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2006-07-26 18:12:59 UTC (rev 9779)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java      
2006-07-26 19:24:44 UTC (rev 9780)
@@ -408,7 +408,7 @@
                                synchronized(this) {
                                        metadataPutter = new 
SingleFileInserter(parent, this, newBlock, true, ctx, false, getCHKOnly, false, 
token, false);
                                }
-                               Logger.minor(this, "Putting metadata on 
"+metadataPutter);
+                               Logger.minor(this, "Putting metadata on 
"+metadataPutter+" from "+sfi+" ("+((SplitFileInserter)sfi).getLength());
                        } catch (InserterException e1) {
                                cb.onFailure(e1, this);
                                return;

Modified: trunk/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserter.java       
2006-07-26 18:12:59 UTC (rev 9779)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserter.java       
2006-07-26 19:24:44 UTC (rev 9780)
@@ -230,14 +230,17 @@
        }

        public void segmentHasURIs(SplitFileInserterSegment segment) {
+               Logger.minor(this, "Segment has URIs: "+segment);
                synchronized(this) {
                        if(haveSentMetadata) {
                                return;
                        }

                        for(int i=0;i<segments.length;i++) {
-                               if(!segments[i].hasURIs())
+                               if(!segments[i].hasURIs()) {
+                                       Logger.minor(this, "Segment does not 
have URIs: "+segments[i]);
                                        return;
+                               }
                        }
                }

@@ -324,7 +327,7 @@
        }

        public void segmentFinished(SplitFileInserterSegment segment) {
-               Logger.minor(this, "Segment finished: "+segment);
+               Logger.minor(this, "Segment finished: "+segment, new 
Exception("debug"));
                boolean allGone = true;
                if(countDataBlocks > 32)
                        parent.onMajorProgress();
@@ -399,4 +402,8 @@
                return token;
        }

+       public long getLength() {
+               return dataLength;
+       }
+
 }

Modified: trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java        
2006-07-26 18:12:59 UTC (rev 9779)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java        
2006-07-26 19:24:44 UTC (rev 9780)
@@ -113,6 +113,7 @@
                        if(blockFinished && dataURIs[i] == null)
                                throw new ResumeException("Block "+i+" of 
"+segNo+" finished but no URI");
                        if(!blockFinished) {
+                               finished = false;
                                // Read data
                                SimpleFieldSet bucketFS = 
blockFS.subset("Data");
                                if(bucketFS == null)
@@ -145,8 +146,8 @@
                                SimpleFieldSet blockFS = 
checkFS.subset(Integer.toString(i));
                                if(blockFS == null) {
                                        hasURIs = false;
-                                       if(encoded) throw new 
ResumeException("No check block "+i+" of "+segNo);
-                                       else continue;
+                                       encoded = false;
+                                       continue;
                                }
                                tmp = blockFS.get("URI");
                                if(tmp != null) {
@@ -179,6 +180,8 @@
                                                throw new 
ResumeException("Check block "+i+" of "+segNo+" not finished but no data 
(create returned null)");
                                // Don't create fetcher yet; that happens in 
start()
                                } else blocksCompleted++;
+                               if(checkBlocks[i] == null && checkURIs[i] == 
null)
+                                       encoded = false;
                        }
                        splitfileAlgo = FECCodec.getCodec(splitfileAlgorithm, 
dataBlockCount, checkBlocks.length);
                } else {
@@ -190,6 +193,13 @@
                        this.checkBlockInserters = new 
SingleBlockInserter[checkBlocksCount];
                        hasURIs = false;
                }
+               if(!encoded) {
+                       finished = false;
+                       hasURIs = false;
+                       for(int i=0;i<dataBlocks.length;i++)
+                               if(dataBlocks[i] == null)
+                                       throw new ResumeException("Missing data 
block "+i+" and need to reconstruct check blocks");
+               }
                parent.parent.addBlocks(dataURIs.length+checkURIs.length);
                
parent.parent.addMustSucceedBlocks(dataURIs.length+checkURIs.length);
        }
@@ -268,6 +278,7 @@
        }

        public void start() throws InserterException {
+               Logger.minor(this, "Starting segment "+segNo+" of "+parent+" 
("+parent.dataLength+"): "+this+" ( finished="+finished+" encoded="+encoded+" 
hasURIs="+hasURIs+")");
                boolean fin = true;
                for(int i=0;i<dataBlockInserters.length;i++) {
                        if(dataBlocks[i] != null) { // else already finished on 
creation
@@ -281,7 +292,10 @@
                }
                //parent.parent.notifyClients();
                started = true;
+               if(!encoded)
+                       Logger.minor(this, "Segment "+segNo+" of "+parent+" 
("+parent.dataLength+") is not encoded");
                if(splitfileAlgo != null && !encoded) {
+                       Logger.minor(this, "Encoding segment "+segNo+" of 
"+parent+" ("+parent.dataLength+")");
                        // Encode blocks
                        Thread t = new Thread(new EncodeBlocksRunnable(), 
"Blocks encoder");
                        t.setDaemon(true);
@@ -336,6 +350,7 @@
                                new 
InserterException(InserterException.BUCKET_ERROR, e, null);
                        finish(ex);
                } catch (Throwable t) {
+                       Logger.error(this, "Caught "+t+" while encoding "+this, 
t);
                        InserterException ex = 
                                new 
InserterException(InserterException.INTERNAL_ERROR, t, null);
                        finish(ex);
@@ -343,6 +358,7 @@
        }

        private void finish(InserterException ex) {
+               Logger.minor(this, "Finishing "+this+" with "+ex, ex);
                synchronized(this) {
                        if(finished) return;
                        finished = true;
@@ -368,13 +384,11 @@
                        if(finished) return;
                        if(x >= dataBlocks.length) {
                                if(checkURIs[x-dataBlocks.length] != null) {
-                                       Logger.normal(this, "Got uri twice for 
check block "+x+" on "+this);
                                        return;
                                }
                                checkURIs[x-dataBlocks.length] = uri;
                        } else {
                                if(dataURIs[x] != null) {
-                                       Logger.normal(this, "Got uri twice for 
data block "+x+" on "+this);
                                        return;
                                }
                                dataURIs[x] = uri;

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-07-26 18:12:59 UTC (rev 
9779)
+++ trunk/freenet/src/freenet/node/Version.java 2006-07-26 19:24:44 UTC (rev 
9780)
@@ -18,7 +18,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 906;
+       private static final int buildNumber = 907;

        /** Oldest build of Fred we will talk to */
        private static final int oldLastGoodBuild = 870;


Reply via email to