Author: toad
Date: 2008-08-01 18:08:13 +0000 (Fri, 01 Aug 2008)
New Revision: 21560
Modified:
trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
Log:
If an offer is valid, and we can't take it up immediately because we are
downloading the update over Freenet, add the source to nodesOfferedMainJar so
we will know where to get it from when/if we timeout.
Improves updater reliability (back to where it was before recent changes).
Sorry for stepping on nextgens' toes, but this code is important...
Modified: trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
2008-08-01 18:02:47 UTC (rev 21559)
+++ trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
2008-08-01 18:08:13 UTC (rev 21560)
@@ -214,9 +214,13 @@
boolean isOutdated = updateManager.node.isOudated();
// if the new build is self-mandatory or if the "normal"
updater has been trying to update for more than one hour
Logger.normal(this, "We received a valid UOMAnnounce :
(isOutdated="+isOutdated+" version="+mainJarVersion +"
whenToTakeOverTheNormalUpdater="+TimeUtil.formatTime(whenToTakeOverTheNormalUpdater-now)+')');
+ if(mainJarVersion > Version.buildNumber() && mainJarFileLength
> 0 &&
+ mainJarVersion >
updateManager.newMainJarVersion()) {
+ // Offer is valid.
if((isOutdated) || (whenToTakeOverTheNormalUpdater > 0 &&
whenToTakeOverTheNormalUpdater < now)) {
- if(mainJarVersion > Version.buildNumber() &&
mainJarFileLength > 0 &&
- mainJarVersion >
updateManager.newMainJarVersion()) {
+ // Take up the offer, subject to limits on number of
simultaneous downloads.
+ // If we have fetches running already, then
sendUOMRequestMain() will add the offer to nodesOfferedMainJar,
+ // so that if all our fetches fail, we can fetch from
this node.
if(!isOutdated) {
Logger.error(this, "The update process
seems to have been stuck for over an hour; let's switch to UoM! SHOULD NOT
HAPPEN!");
System.out.println("The update process
seems to have been stuck for over an hour; let's switch to UoM! SHOULD NOT
HAPPEN!");
@@ -234,8 +238,13 @@
Logger.error(this, "Node " + source + "
sent us a UOMAnnounce claiming to have a new jar, but it had an invalid URI: "
+ revocationKey + " : " + e, e);
System.err.println("Node " +
source.userToString() + " sent us a UOMAnnounce claiming to have a new jar, but
it had an invalid URI: " + revocationKey + " : " + e);
}
+ } else {
+ // Don't take up the offer. Add to nodesOfferedMainJar,
so that we know where to fetch it from when we need it.
+ synchronized(this) {
+ nodesOfferedMainJar.add(source);
}
}
+ }
return true;
}