r27110 - trunk/freenet/src/freenet/client/async

[email protected] Mon, 20 Apr 2009 20:05:27 +0000
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: toad
Date: 2009-04-20 20:05:27 +0000 (Mon, 20 Apr 2009)
New Revision: 27110

Modified:
   trunk/freenet/src/freenet/client/async/USKFetcher.java
Log:
Don't assume we've checked slot 0.
Update checkedDatastoreUpTo in preRegister.
Logging, comments.


Modified: trunk/freenet/src/freenet/client/async/USKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKFetcher.java	2009-04-20 20:04:22 UTC (rev 27109)
+++ trunk/freenet/src/freenet/client/async/USKFetcher.java	2009-04-20 20:05:27 UTC (rev 27110)
@@ -125,7 +125,7 @@
 	/** A list of keys which we are interested in. This a sequence of SSKs starting 
 	 * at the last known slot. */
 	private final ArrayList<ClientSSK> keysWatching;
-	private long checkedDatastoreUpTo;
+	private long checkedDatastoreUpTo = -1;
 	private final ArrayList<USKAttempt> attemptsToStart;
 	
 	private static final int WATCH_KEYS = 50;
@@ -735,6 +735,7 @@
 		if(runningStoreChecker) return;
 		long firstCheck = Math.max(firstKeyWatching, checkedDatastoreUpTo + 1);
 		final long lastCheck = firstKeyWatching + keysWatching.size() - 1;
+		if(logMINOR) Logger.minor(this, "firstCheck="+firstCheck+" lastCheck="+lastCheck);
 		if(lastCheck < firstCheck) return;
 		int checkCount = (int) (lastCheck - firstCheck + 1);
 		int offset = (int) (firstCheck - firstKeyWatching);
@@ -814,6 +815,7 @@
 					attempts = attemptsToStart.toArray(new USKAttempt[attemptsToStart.size()]);
 					attemptsToStart.clear();
 					done = true;
+					checkedDatastoreUpTo = lastCheck;
 				}
 				if(logMINOR) Logger.minor(this, "Checked datastore, finishing registration for "+attempts.length+" checkers for "+USKFetcher.this+" for "+origUSK);
 				for(int i=0;i<attempts.length;i++) {
@@ -831,6 +833,7 @@
 					}
 				}
 				long lastEd = uskManager.lookupLatestSlot(origUSK);
+				// Do not check beyond WATCH_KEYS after the current slot.
 				fillKeysWatching(lastEd, context);
 			}
 
@@ -851,9 +854,6 @@
 
 			@Override
 			public RequestClient getClient(ObjectContainer container) {
-				synchronized(USKFetcher.this) {
-					checkedDatastoreUpTo = lastCheck;
-				}
 				return USKFetcher.this.uskManager;
 			}