Author: toad
Date: 2006-06-03 00:04:42 +0000 (Sat, 03 Jun 2006)
New Revision: 9013
Modified:
trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
trunk/freenet/src/freenet/node/TextModeClientInterface.java
trunk/freenet/src/freenet/node/updater/NodeUpdater.java
Log:
771: more work on updating
Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-06-02
22:05:07 UTC (rev 9012)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-06-03
00:04:42 UTC (rev 9013)
@@ -95,6 +95,7 @@
writeReply(ctx, 200, "text/html", "OK", buf.toString());
Logger.normal(this, "Node is updating/restarting");
+ // FIXME run on separate thread
node.getNodeUpdater().Update();
return;
}else if (request.getParam("restart").length() > 0) {
Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-06-02
22:05:07 UTC (rev 9012)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-06-03
00:04:42 UTC (rev 9013)
@@ -300,6 +300,7 @@
}
} else if(uline.startsWith("UPDATE")) {
outsb.append("starting the update process");
+ // FIXME run on separate thread
n.getNodeUpdater().Update();
return false;
}else if(uline.startsWith("BLOW")) {
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-06-02
22:05:07 UTC (rev 9012)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-06-03
00:04:42 UTC (rev 9013)
@@ -161,29 +161,33 @@
* We try to update the node :p
* Must run on its own thread.
*/
- public synchronized void Update(){
+ public void Update(){
Logger.minor(this, "Update() called");
- if((result == null) || hasBeenBlown) {
- Logger.minor(this, "Returning: result="+result+",
isAutoUpdateAllowed="+isAutoUpdateAllowed+", hasBeenBlown="+hasBeenBlown);
- return;
+ synchronized(this) {
+ if((result == null) || hasBeenBlown) {
+ Logger.minor(this, "Returning:
result="+result+", isAutoUpdateAllowed="+isAutoUpdateAllowed+",
hasBeenBlown="+hasBeenBlown);
+ return;
+ }
+
+ this.revocationDNFCounter = 0;
+ this.finalCheck = true;
}
-
- this.revocationDNFCounter = 0;
- this.finalCheck = true;
System.err.println("Searching for revocation key");
this.queueFetchRevocation(100);
- while(revocationDNFCounter < 3) {
- System.err.println("Revocation counter:
"+revocationDNFCounter);
- if(this.hasBeenBlown) {
- Logger.error(this, "The revocation key has been
found on the network : blocking auto-update");
- return;
+ synchronized(this) {
+ while(revocationDNFCounter < 3) {
+ System.err.println("Revocation counter:
"+revocationDNFCounter);
+ if(this.hasBeenBlown) {
+ Logger.error(this, "The revocation key
has been found on the network : blocking auto-update");
+ return;
+ }
+ try {
+ wait(100*1000);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
}
- try {
- wait(100*1000);
- } catch (InterruptedException e) {
- // Ignore
- }
}
System.err.println("Update in progress");
@@ -363,7 +367,7 @@
}
}
- public synchronized void onFailure(FetchException e, ClientGetter
state) {
+ public void onFailure(FetchException e, ClientGetter state) {
int errorCode = e.getMode();
if(!state.getURI().equals(revocationURI)){
@@ -380,20 +384,22 @@
}else
Logger.error(this, "Canceling fetch : "+
e.getMessage());
}else{
- if(errorCode == FetchException.DATA_NOT_FOUND){
- revocationDNFCounter++;
+ synchronized(this) {
+ if(errorCode == FetchException.DATA_NOT_FOUND){
+ revocationDNFCounter++;
+ }
+ // Start it again
+ if(this.finalCheck) {
+ if(revocationDNFCounter < 3)
+ queueFetchRevocation(1000);
+ else
+ notifyAll();
+ } else {
+ boolean pause = (revocationDNFCounter
== 3);
+ if(pause) revocationDNFCounter = 0;
+ queueFetchRevocation(pause ? 60*60*1000
: 5000);
+ }
}
- // Start it again
- if(this.finalCheck) {
- if(revocationDNFCounter < 3)
- queueFetchRevocation(1000);
- else
- notifyAll();
- } else {
- boolean pause = (revocationDNFCounter == 3);
- if(pause) revocationDNFCounter = 0;
- queueFetchRevocation(pause ? 60*60*1000 : 5000);
- }
}
}