Author: toad
Date: 2008-10-22 12:26:54 +0000 (Wed, 22 Oct 2008)
New Revision: 23025

Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
Log:
Fix ignoring transition because current = null, hence fix most cases of OOM on 
startup due to fetchers not getting cancelled.
Logging.


Modified: branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientGetter.java    
2008-10-22 10:16:08 UTC (rev 23024)
+++ branches/db4o/freenet/src/freenet/client/async/ClientGetter.java    
2008-10-22 12:26:54 UTC (rev 23025)
@@ -103,8 +103,10 @@
                        }
                        if(cancelled) cancel();
                        // schedule() may deactivate stuff, so store it now.
-                       if(persistent())
+                       if(persistent()) {
                                container.store(currentState);
+                               container.store(this);
+                       }
                        if(currentState != null && !finished) {
                                if(binaryBlobBucket != null) {
                                        try {
@@ -134,7 +136,7 @@

        public void onSuccess(FetchResult result, ClientGetState state, 
ObjectContainer container, ClientContext context) {
                if(Logger.shouldLog(Logger.MINOR, this))
-                       Logger.minor(this, "Succeeded from "+state);
+                       Logger.minor(this, "Succeeded from "+state+" on "+this);
                if(!closeBinaryBlobStream(container, context)) return;
                synchronized(this) {
                        finished = true;
@@ -178,7 +180,7 @@

        public void onFailure(FetchException e, ClientGetState state, 
ObjectContainer container, ClientContext context) {
                if(Logger.shouldLog(Logger.MINOR, this))
-                       Logger.minor(this, "Failed from "+state+" : "+e, e);
+                       Logger.minor(this, "Failed from "+state+" : "+e+" on 
"+this, e);
                closeBinaryBlobStream(container, context);
                while(true) {
                        if(e.mode == FetchException.ARCHIVE_RESTART) {
@@ -235,6 +237,8 @@
                        s.cancel(container, context);
                        if(persistent())
                                container.deactivate(s, 1);
+               } else {
+                       if(logMINOR) Logger.minor(this, "Nothing to cancel");
                }
        }

@@ -267,9 +271,9 @@
                synchronized(this) {
                        if(currentState == oldState) {
                                currentState = newState;
-                               Logger.minor(this, "Transition: "+oldState+" -> 
"+newState);
+                               Logger.minor(this, "Transition: "+oldState+" -> 
"+newState+" on "+this);
                        } else
-                               Logger.minor(this, "Ignoring transition: 
"+oldState+" -> "+newState+" because current = "+currentState);
+                               Logger.minor(this, "Ignoring transition: 
"+oldState+" -> "+newState+" because current = "+currentState+" on "+this);
                }
                if(persistent())
                        container.store(this);


Reply via email to