Author: toad
Date: 2007-07-24 17:55:02 +0000 (Tue, 24 Jul 2007)
New Revision: 14319

Modified:
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
   trunk/freenet/src/freenet/node/SendableGet.java
Log:
Unregister single keys when we are finished with them (fatal failure), to avoid 
a memory leak

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2007-07-24 17:49:24 UTC (rev 14318)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2007-07-24 17:55:02 UTC (rev 14319)
@@ -322,6 +322,8 @@
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR) Logger.minor(this, "Permanently failed block: 
"+blockNo+" on "+this+" : "+e, e);
                boolean allFailed;
+               // Since we can't keep the key, we need to unregister for it at 
this point to avoid a memory leak
+               seg.unregisterKey(getBlockKey(blockNo).getNodeKey());
                synchronized(this) {
                        if(isFinishing()) return; // this failure is now 
irrelevant, and cleanup will occur on the decoder thread
                        if(blockNo < dataKeys.length) {

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2007-07-24 17:49:24 UTC (rev 14318)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2007-07-24 17:55:02 UTC (rev 14319)
@@ -300,5 +300,5 @@
                }
                segment.removeSeg(this);
        }
-       
+
 }

Modified: trunk/freenet/src/freenet/node/SendableGet.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableGet.java     2007-07-24 17:49:24 UTC 
(rev 14318)
+++ trunk/freenet/src/freenet/node/SendableGet.java     2007-07-24 17:55:02 UTC 
(rev 14319)
@@ -122,4 +122,8 @@
                super.unregister();
        }

+       public final void unregisterKey(Key key) {
+               getScheduler().removePendingKey(this, false, key);
+       }
+       
 }


Reply via email to