Author: toad
Date: 2009-03-25 21:08:09 +0000 (Wed, 25 Mar 2009)
New Revision: 26189
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
Log:
Cancel-related bugfixes, plus a store(,2) fix
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2009-03-25 21:07:22 UTC (rev 26188)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2009-03-25 21:08:09 UTC (rev 26189)
@@ -129,7 +129,6 @@
ClientPutState oldState = null;
synchronized(this) {
if(cancelled) return;
- if(finished) return;
super.cancel();
oldState = currentState;
}
@@ -197,7 +196,7 @@
container.activate(putHandlersWaitingForFetchable, 2);
if(putHandlersWaitingForFetchable.contains(this)) {
putHandlersWaitingForFetchable.remove(this);
-
container.store(putHandlersWaitingForFetchable);
+
container.ext().store(putHandlersWaitingForFetchable, 2);
// Not getting an onFetchable is not
unusual, just ignore it.
if(logMINOR) Logger.minor(this,
"PutHandler was in waitingForFetchable in onSuccess() on "+this+" for
"+SimpleManifestPutter.this);
}
@@ -467,13 +466,13 @@
currentState = null;
}
if(oldSFI != null) {
- Logger.error(this, "origSFI is set in
removeFrom() on "+this+" for "+SimpleManifestPutter.this);
+ Logger.error(this, "origSFI is set in
removeFrom() on "+this+" for "+SimpleManifestPutter.this, new
Exception("debug"));
oldSFI.cancel(container, context);
oldSFI.removeFrom(container, context);
if(oldState == oldSFI) oldState = null;
}
if(oldState != null) {
- Logger.error(this, "currentState is set in
removeFrom() on "+this+" for "+SimpleManifestPutter.this);
+ Logger.error(this, "currentState is set in
removeFrom() on "+this+" for "+SimpleManifestPutter.this, new
Exception("debug"));
oldState.cancel(container, context);
oldState.removeFrom(container, context);
}
@@ -583,7 +582,10 @@
gotAllMetadata(container, context);
}
} catch (InsertException e) {
- cancelAndFinish(container);
+ synchronized(this) {
+ finished = true;
+ }
+ cancelAndFinish(container, context);
throw e;
}
}
@@ -1071,7 +1073,11 @@
private void fail(InsertException e, ObjectContainer container,
ClientContext context) {
// Cancel all, then call the callback
- cancelAndFinish(container);
+ synchronized(this) {
+ if(finished) return;
+ finished = true;
+ }
+ cancelAndFinish(container, context);
if(persistent()) removePutHandlers(container, context);
if(persistent())
@@ -1198,20 +1204,21 @@
/**
* Cancel all running inserters and set finished to true.
*/
- private void cancelAndFinish(ObjectContainer container) {
+ private void cancelAndFinish(ObjectContainer container, ClientContext
context) {
PutHandler[] running;
- if(persistent())
+ boolean persistent = persistent();
+ if(persistent)
container.activate(runningPutHandlers, 2);
synchronized(this) {
- if(finished) return;
running = (PutHandler[]) runningPutHandlers.toArray(new
PutHandler[runningPutHandlers.size()]);
- finished = true;
}
if(persistent())
container.store(this);
for(int i=0;i<running.length;i++) {
- running[i].cancel();
+ if(persistent) container.activate(running[i], 1);
+ running[i].cancel(container, context);
+ if(persistent) container.activate(this, 1);
}
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs