Author: toad
Date: 2009-03-11 16:36:06 +0000 (Wed, 11 Mar 2009)
New Revision: 25988

Modified:
   branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
Log:
Don't call fail(), which calls the callback, until we have cancelled and nulled 
out both sfi and metadataPutter. When one fails, kill the other, which will 
callback to onFailure, which will null it out and call fail(); the first won't 
call fail()


Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2009-03-11 16:32:37 UTC (rev 25987)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java      
2009-03-11 16:36:06 UTC (rev 25988)
@@ -618,15 +618,26 @@
                        if(persistent) {
                                container.activate(block, 1);
                        }
+                       ClientPutState killMe = null;
                        boolean toFail = true;
                        boolean toRemove = false;
                        synchronized(this) {
                                if(state == sfi) {
                                        toRemove = true;
                                        sfi = null;
+                                       if(metadataPutter != null) {
+                                               toFail = false;
+                                               killMe = metadataPutter;
+                                               if(persistent) 
container.store(this);
+                                       }
                                } else if(state == metadataPutter) {
                                        toRemove = true;
                                        metadataPutter = null;
+                                       if(sfi != null) {
+                                               toFail = false;
+                                               killMe = sfi;
+                                               if(persistent) 
container.store(this);
+                                       }
                                } else {
                                        Logger.error(this, "onFailure() on 
unknown state "+state+" on "+this);
                                }
@@ -636,6 +647,11 @@
                        }
                        if(toRemove && persistent)
                                state.removeFrom(container, context);
+                       if(killMe != null) {
+                               if(logMINOR) Logger.minor(this, "onFailure: 
killing "+killMe);
+                               killMe.cancel(container, context);
+                               // Should call back here and finish it
+                       }
                        if(toFail)
                        fail(e, container, context);
                }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to