Author: toad
Date: 2009-03-07 20:31:49 +0000 (Sat, 07 Mar 2009)
New Revision: 25948
Modified:
branches/db4o/freenet/src/freenet/client/async/USKInserter.java
Log:
More USK database leak fixes
Modified: branches/db4o/freenet/src/freenet/client/async/USKInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/USKInserter.java
2009-03-07 20:30:55 UTC (rev 25947)
+++ branches/db4o/freenet/src/freenet/client/async/USKInserter.java
2009-03-07 20:31:49 UTC (rev 25948)
@@ -75,11 +75,13 @@
* including author errors and so on.
*/
private void scheduleFetcher(ObjectContainer container, ClientContext
context) {
+ if(persistent)
+ container.activate(pubUSK, 5);
synchronized(this) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "scheduling fetcher for
"+pubUSK.getURI());
if(finished) return;
- fetcher =
context.uskManager.getFetcherForInsertDontSchedule(pubUSK,
parent.priorityClass, this, parent.getClient(), container, context, persistent);
+ fetcher =
context.uskManager.getFetcherForInsertDontSchedule(persistent ? pubUSK.clone()
: pubUSK, parent.priorityClass, this, parent.getClient(), container, context,
persistent);
}
fetcher.schedule(container, context);
}
@@ -107,14 +109,17 @@
fetcher.removeFrom(container, context);
fetcher.ctx.removeFrom(container);
fetcher = null;
+ container.store(this);
}
}
if(alreadyInserted) {
// Success!
parent.addMustSucceedBlocks(1, container);
parent.completedBlock(true, container, context);
- if(persistent)
+ if(persistent) {
container.activate(cb, 1);
+ container.activate(pubUSK, 5);
+ }
cb.onEncode(pubUSK.copy(edition), this, container,
context);
cb.onSuccess(this, container, context);
if(freeData) {
@@ -128,6 +133,10 @@
private void scheduleInsert(ObjectContainer container, ClientContext
context) {
long edNo = Math.max(edition,
context.uskManager.lookup(pubUSK)+1);
+ if(persistent) {
+ container.activate(privUSK, 5);
+ container.activate(pubUSK, 5);
+ }
synchronized(this) {
if(finished) return;
edition = edNo;
@@ -148,14 +157,20 @@
data.removeFrom(container);
}
}
+ if(persistent) container.store(this);
}
public synchronized void onSuccess(ClientPutState state,
ObjectContainer container, ClientContext context) {
+ if(persistent) container.activate(pubUSK, 5);
USK newEdition = pubUSK.copy(edition);
+ finished = true;
+ sbi = null;
+ if(persistent) {
+ container.activate(cb, 1);
+ container.store(this);
+ }
cb.onEncode(newEdition, this, container, context);
cb.onSuccess(this, container, context);
- finished = true;
- sbi = null;
FreenetURI targetURI = pubUSK.getSSK(edition).getURI();
FreenetURI realURI =
((SingleBlockInserter)state).getURI(container, context);
if(!targetURI.equals(realURI))
@@ -177,11 +192,15 @@
if(e.getMode() == InsertException.COLLISION) {
// Try the next slot
edition++;
- if(consecutiveCollisions++ > MAX_TRIED_SLOTS)
+ consecutiveCollisions++;
+ if(persistent) container.store(this);
+ if(consecutiveCollisions > MAX_TRIED_SLOTS)
scheduleFetcher(container, context);
else
scheduleInsert(container, context);
} else {
+ if(persistent)
+ container.activate(cb, 1);
cb.onFailure(e, state, container, context);
}
}
@@ -320,15 +339,19 @@
// ctx is passed in, cb will deal with
// cb will remove self
// tokenObject will be removed by creator
+ container.activate(privUSK, 5);
privUSK.removeFrom(container);
+ container.activate(pubUSK, 5);
pubUSK.removeFrom(container);
if(fetcher != null) {
Logger.error(this, "Fetcher tag still present:
"+fetcher+" in removeFrom() for "+this, new Exception("debug"));
+ container.activate(fetcher.ctx, 2);
fetcher.ctx.removeFrom(container);
fetcher.removeFrom(container, context);
}
if(sbi != null) {
Logger.error(this, "sbi still present: "+sbi+" in
removeFrom() for "+this);
+ container.activate(sbi, 1);
sbi.removeFrom(container, context);
}
container.delete(this);
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs