Author: toad
Date: 2008-03-24 23:40:27 +0000 (Mon, 24 Mar 2008)
New Revision: 18760

Modified:
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
Log:
Locking

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-03-24 23:37:03 UTC (rev 18759)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-03-24 23:40:27 UTC (rev 18760)
@@ -258,6 +258,7 @@
        }

        public void onEncodedSegment() {
+               synchronized(this) {
                // Now insert *ALL* blocks on which we had at least one 
failure, and didn't eventually succeed
                for(int i=0;i<dataBuckets.length;i++) {
                        boolean heal = false;
@@ -292,6 +293,7 @@
                        checkBuckets[i] = null;
                        checkKeys[i] = null;
                }
+               }
                // Defer the completion until we have generated healing blocks 
if we are collecting binary blobs.
                if(isCollectingBinaryBlob())
                        
parentFetcher.segmentFinished(SplitFileFetcherSegment.this);
@@ -496,7 +498,7 @@
                // Ignore
        }

-       public ClientCHK getBlockKey(int blockNum) {
+       public synchronized ClientCHK getBlockKey(int blockNum) {
                if(blockNum < 0) return null;
                else if(blockNum < dataKeys.length)
                        return dataKeys[blockNum];
@@ -556,18 +558,17 @@
                }
        }

-       public long getCooldownWakeup(int blockNum) {
+       public synchronized long getCooldownWakeup(int blockNum) {
                if(blockNum < dataKeys.length)
                        return dataCooldownTimes[blockNum];
                else
                        return checkCooldownTimes[blockNum - dataKeys.length];
        }

-       public void requeueAfterCooldown(Key key, long time) {
+       public synchronized void requeueAfterCooldown(Key key, long time) {
                if(isFinishing()) return;
                boolean notFound = true;
                int maxTries = blockFetchContext.maxNonSplitfileRetries;
-               // FIXME synchronization
                for(int i=0;i<dataKeys.length;i++) {
                        if(dataKeys[i] == null) continue;
                        if(dataKeys[i].getNodeKey().equals(key)) {
@@ -605,7 +606,7 @@
                }
        }

-       public long getCooldownWakeupByKey(Key key) {
+       public synchronized long getCooldownWakeupByKey(Key key) {
                for(int i=0;i<dataKeys.length;i++) {
                        if(dataKeys[i] == null) continue;
                        if(dataKeys[i].getNodeKey().equals(key)) {


Reply via email to