Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix in Kademlia example
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 2 Jul 2012 09:32:02 +0000 (11:32 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 2 Jul 2012 09:32:02 +0000 (11:32 +0200)
examples/kademlia/Node.java

index cdcc71a..e8e4e70 100644 (file)
@@ -182,12 +182,13 @@ public class Node extends Process {
                int nodesAdded = 0;
                boolean destinationFound = false;
                int steps = 0;
                int nodesAdded = 0;
                boolean destinationFound = false;
                int steps = 0;
-               double timeBeginReceive = Msg.getClock();
+               double timeBeginReceive;
                double timeout, globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT;
                //Build a list of the closest nodes we already know.
                Answer nodeList = table.findClosest(destination);
                Msg.debug("Doing a FIND_NODE on " + destination);
                do {
                double timeout, globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT;
                //Build a list of the closest nodes we already know.
                Answer nodeList = table.findClosest(destination);
                Msg.debug("Doing a FIND_NODE on " + destination);
                do {
+                       timeBeginReceive = Msg.getClock();
                        answers = 0;
                        queries = this.sendFindNodeToBest(nodeList);
                        totalQueries += queries;
                        answers = 0;
                        queries = this.sendFindNodeToBest(nodeList);
                        totalQueries += queries;
@@ -220,14 +221,14 @@ public class Node extends Process {
                                                        }
                                                        else {
                                                                handleTask(task);
                                                        }
                                                        else {
                                                                handleTask(task);
-                                                               timeBeginReceive = Msg.getClock();
                                                                timeout += Msg.getClock() - timeBeginReceive;
                                                                timeout += Msg.getClock() - timeBeginReceive;
+                                                               timeBeginReceive = Msg.getClock();
                                                        }
                                                }
                                                else {
                                                        handleTask(task);
                                                        }
                                                }
                                                else {
                                                        handleTask(task);
-                                                       timeBeginReceive = Msg.getClock();
                                                        timeout += Msg.getClock() - timeBeginReceive;
                                                        timeout += Msg.getClock() - timeBeginReceive;
+                                                       timeBeginReceive = Msg.getClock();
                                                }
                                                comm = null;
                                        }
                                                }
                                                comm = null;
                                        }