Author: toad
Date: 2009-03-06 22:40:48 +0000 (Fri, 06 Mar 2009)
New Revision: 25918
Modified:
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
Log:
Missed one
Modified:
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
2009-03-06 22:39:55 UTC (rev 25917)
+++
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
2009-03-06 22:40:48 UTC (rev 25918)
@@ -49,36 +49,45 @@
public void onSuccess(ClientPutState state, ObjectContainer container,
ClientContext context) {
onBlockSetFinished(state, container, context);
onFetchable(state, container);
+ boolean complete = true;
synchronized(this) {
- if(finished) return;
+ if(finished) {
+ Logger.error(this, "Already finished but got
onSuccess() for "+state+" on "+this);
+ return;
+ }
waitingFor.remove(state);
if(!(waitingFor.isEmpty() && started)) {
if(persistent) {
container.store(waitingFor);
}
- return;
+ complete = false;
}
}
+ if(persistent) state.removeFrom(container, context);
+ if(complete) {
Logger.minor(this, "Completing...");
complete(null, container, context);
+ }
}
public void onFailure(InsertException e, ClientPutState state,
ObjectContainer container, ClientContext context) {
+ boolean complete = true;
synchronized(this) {
- if(finished) return;
+ if(finished) {
+ Logger.error(this, "Already finished but got
onFailure() for "+state+" on "+this);
+ return;
+ }
waitingFor.remove(state);
waitingForBlockSet.remove(state);
waitingForFetchable.remove(state);
if(!(waitingFor.isEmpty() && started)) {
- if(persistent) {
- container.store(waitingFor);
- container.store(waitingForBlockSet);
- container.store(waitingForFetchable);
+ if(this.e != null) {
+ if(persistent)
this.e.removeFrom(container);
}
this.e = e;
if(persistent)
container.store(this);
- return;
+ complete = false;
}
}
if(persistent) {
@@ -86,6 +95,8 @@
container.store(waitingForBlockSet);
container.store(waitingForFetchable);
}
+ if(persistent) state.removeFrom(container, context);
+ if(complete)
complete(e, container, context);
}
@@ -97,7 +108,13 @@
if(!(e.getMode() == InsertException.CANCELLED))
// Cancelled is okay, ignore it, we cancel after failure sometimes.
Logger.error(this, "Completing with
"+e+" but already set "+this.e);
}
- if(e == null) e = this.e;
+ if(e == null) {
+ e = this.e;
+ if(persistent) {
+ container.activate(e, 10);
+ e = e.clone(); // Since we will remove
it, we can't pass it on
+ }
+ }
}
if(persistent) {
container.store(this);
@@ -245,4 +262,26 @@
cb.onFetchable(this, container);
}
+ public void removeFrom(ObjectContainer container, ClientContext
context) {
+ container.activate(waitingFor, 2);
+ container.activate(waitingForBlockSet, 2);
+ container.activate(waitingForFetchable, 2);
+ // Should have been cleared by now
+ if(!waitingFor.isEmpty())
+ Logger.error(this, "waitingFor not empty in
removeFrom() on "+this+" : "+waitingFor);
+ if(!waitingForBlockSet.isEmpty())
+ Logger.error(this, "waitingForBlockSet not empty in
removeFrom() on "+this+" : "+waitingFor);
+ if(!waitingForFetchable.isEmpty())
+ Logger.error(this, "waitingForFetchable not empty in
removeFrom() on "+this+" : "+waitingFor);
+ container.delete(waitingFor);
+ container.delete(waitingForBlockSet);
+ container.delete(waitingForFetchable);
+ // cb is at a higher level, we don't remove that, it removes
itself
+ // generator is just a reference to one of the waitingFor's
+ // parent removes itself
+ e.removeFrom(container);
+ // whoever set the token is responsible for removing it
+ container.delete(this);
+ }
+
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs