Author: robert
Date: 2007-12-19 17:50:12 +0000 (Wed, 19 Dec 2007)
New Revision: 16727

Modified:
   trunk/freenet/src/freenet/node/CHKInsertSender.java
Log:
only start backgroundtransfers for nodes accepting the insert (latency increase)


Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertSender.java 2007-12-19 17:29:48 UTC 
(rev 16726)
+++ trunk/freenet/src/freenet/node/CHKInsertSender.java 2007-12-19 17:50:12 UTC 
(rev 16727)
@@ -362,12 +362,6 @@

                        if(logMINOR) Logger.minor(this, "Sending data");
             if(receiveFailed) return;
-            BackgroundTransfer ac = new BackgroundTransfer(next, prbNow);
-            synchronized(backgroundTransfers) {
-               backgroundTransfers.add(ac);
-               backgroundTransfers.notifyAll();
-            }
-            ac.start();

             while (true) {

@@ -419,6 +413,8 @@
                                        }
                                        // Finished as far as this node is 
concerned
                                        next.successNotOverload();
+                                       //RNF means that the HTL was not 
exhausted, but that the data should still be sent.
+                                       startBackgroundTransfer(next, prb);
                                        break;
                                }

@@ -480,9 +476,11 @@
                                        Logger.error(this, "Unknown reply: " + 
msg);
                                        finish(INTERNAL_ERROR, next);
                                        return;
-                               }else{
+                               } else {
                                        // Our task is complete, one node 
(quite deep), has accepted the insert.
                                        next.successNotOverload();
+                                       // The request will not be routed to 
any other nodes, this is where the data *should* be.
+                                       startBackgroundTransfer(next, prb);
                                        finish(SUCCESS, next);
                                        return;
                                }
@@ -491,6 +489,15 @@
                }
        }

+       private void startBackgroundTransfer(PeerNode node, 
PartiallyReceivedBlock prb) {
+               BackgroundTransfer ac = new BackgroundTransfer(node, prb);
+               synchronized(backgroundTransfers) {
+                       backgroundTransfers.add(ac);
+                       backgroundTransfers.notifyAll();
+               }
+               ac.start();
+       }
+       
        private boolean hasForwardedRejectedOverload;

     synchronized boolean receivedRejectedOverload() {


Reply via email to