Author: j16sdiz
Date: 2008-11-06 08:44:13 +0000 (Thu, 06 Nov 2008)
New Revision: 23338
Modified:
trunk/freenet/src/freenet/client/async/ClientPutter.java
trunk/freenet/src/freenet/client/async/ClientRequester.java
Log:
move logger out from synchronized block
the addBlock() bug is causing watchdog timeout on my machine
this make it feel a bit easier.
Modified: trunk/freenet/src/freenet/client/async/ClientPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientPutter.java 2008-11-06
08:43:52 UTC (rev 23337)
+++ trunk/freenet/src/freenet/client/async/ClientPutter.java 2008-11-06
08:44:13 UTC (rev 23338)
@@ -231,12 +231,16 @@
return uri;
}
- public synchronized void onTransition(ClientPutState oldState,
ClientPutState newState) {
+ public void onTransition(ClientPutState oldState, ClientPutState
newState) {
if(newState == null) throw new NullPointerException();
- if(currentState == oldState)
- currentState = newState;
- else
- Logger.error(this, "onTransition: cur="+currentState+",
old="+oldState+", new="+newState);
+
+ synchronized (this) {
+ if (currentState == oldState) {
+ currentState = newState;
+ return;
+ }
+ }
+ Logger.error(this, "onTransition: cur=" + currentState + ",
old=" + oldState + ", new=" + newState);
}
public void onMetadata(Metadata m, ClientPutState state) {
Modified: trunk/freenet/src/freenet/client/async/ClientRequester.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequester.java 2008-11-06
08:43:52 UTC (rev 23337)
+++ trunk/freenet/src/freenet/client/async/ClientRequester.java 2008-11-06
08:44:13 UTC (rev 23338)
@@ -68,23 +68,36 @@
notifyClients();
}
- public synchronized void addBlock() {
- if(blockSetFinalized)
- if(Logger.globalGetThreshold() > Logger.MINOR)
- Logger.error(this, "addBlock() but set
finalized! on "+this);
+ public void addBlock() {
+ boolean wasFinalized;
+ synchronized (this) {
+ totalBlocks++;
+ wasFinalized = blockSetFinalized;
+ }
+
+ if (wasFinalized) {
+ if (Logger.globalGetThreshold() > Logger.MINOR)
+ Logger.error(this, "addBlock() but set
finalized! on " + this);
else
- Logger.error(this, "addBlock() but set
finalized! on "+this, new Exception("error"));
- totalBlocks++;
+ Logger.error(this, "addBlock() but set
finalized! on " + this, new Exception("error"));
+ }
+
if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this,
"addBlock(): total="+totalBlocks+" successful="+successfulBlocks+"
failed="+failedBlocks+" required="+minSuccessBlocks);
}
- public synchronized void addBlocks(int num) {
- if(blockSetFinalized)
+ public void addBlocks(int num) {
+ boolean wasFinalized;
+ synchronized (this) {
+ totalBlocks += num;
+ wasFinalized = blockSetFinalized;
+ }
+
+ if (wasFinalized)
if(Logger.globalGetThreshold() > Logger.MINOR)
Logger.error(this, "addBlocks() but set
finalized! on "+this);
else
Logger.error(this, "addBlocks() but set
finalized! on "+this, new Exception("error"));
- totalBlocks+=num;
+
if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this,
"addBlocks("+num+"): total="+totalBlocks+" successful="+successfulBlocks+"
failed="+failedBlocks+" required="+minSuccessBlocks);
}