Author: toad
Date: 2008-06-30 23:21:30 +0000 (Mon, 30 Jun 2008)
New Revision: 20882

Modified:
   branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
   branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
Log:
Various activation and database updating

Modified: 
branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-06-30 23:00:46 UTC (rev 20881)
+++ branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-06-30 23:21:30 UTC (rev 20882)
@@ -77,9 +77,6 @@
        /** Try again - returns true if we can retry 
         * @param sched */
        protected boolean retry(ObjectContainer container, ClientContext 
context) {
-               if(persistent) {
-                       container.activate(this, 1);
-               }
                retryCount++;
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Attempting to retry... (max 
"+maxRetries+", current "+retryCount+ ')');
@@ -158,6 +155,8 @@
                        container.activate(this, 2);
                synchronized(this) {
                        finished = true;
+                       if(persistent)
+                               container.set(this);
                        if(isCancelled(container)) return;
                        if(!key.equals(this.key.getNodeKey())) {
                                Logger.normal(this, "Got sent key "+key+" but 
want "+this.key+" for "+this);
@@ -183,6 +182,8 @@

        public synchronized void resetCooldownTimes(ObjectContainer container) {
                cooldownWakeupTime = -1;
+               if(persistent)
+                       container.set(this);
        }

        public void requeueAfterCooldown(Key key, long time, ObjectContainer 
container, ClientContext context) {

Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-06-30 23:00:46 UTC (rev 20881)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java       
2008-06-30 23:21:30 UTC (rev 20882)
@@ -183,6 +183,12 @@

        protected void onSuccess(FetchResult result, ObjectContainer container, 
ClientContext context) {
                unregister(false, container);
+               if(persistent) {
+                       container.activate(decompressors, 1);
+                       container.activate(parent, 1);
+                       container.activate(ctx, 1);
+                       container.activate(rcb, 1);
+               }
                if(parent.isCancelled()) {
                        if(logMINOR)
                                Logger.minor(this, "Parent is cancelled");
@@ -190,12 +196,6 @@
                        onFailure(new FetchException(FetchException.CANCELLED), 
false, container, context);
                        return;
                }
-               if(persistent) {
-                       container.activate(decompressors, 1);
-                       container.activate(parent, 1);
-                       container.activate(ctx, 1);
-                       container.activate(rcb, 1);
-               }
                if(!decompressors.isEmpty()) {
                        Bucket data = result.asBucket();
                        while(!decompressors.isEmpty()) {
@@ -410,6 +410,8 @@
                                                        try {
                                                                // Data will 
not be freed until client is finished with it.
                                                                if(returnBucket 
!= null) {
+                                                                       
if(persistent)
+                                                                               
container.activate(returnBucket, 5);
                                                                        out = 
returnBucket;
                                                                        
BucketTools.copy(data, out);
                                                                        
data.free();
@@ -647,6 +649,7 @@
                        if(!context.jobRunner.onDatabaseThread())
                                context.jobRunner.queue(new DBJob() {
                                        public void run(ObjectContainer 
container, ClientContext context) {
+                                               
container.activate(SingleFileFetcher.this, 1);
                                                
innerWrapHandleMetadata(notFinalizedSize, container, context);
                                        }
                                }, parent.getPriorityClass(), false);
@@ -768,6 +771,8 @@
                                container.activate(SingleFileFetcher.this, 1);
                        try {
                                metadata = 
Metadata.construct(result.asBucket());
+                               if(persistent)
+                                       container.set(SingleFileFetcher.this);
                        } catch (MetadataParseException e) {
                                SingleFileFetcher.this.onFailure(new 
FetchException(FetchException.INVALID_METADATA, e), false, container, context);
                                return;


Reply via email to