Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
partial leak plug in chord
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 25 Jul 2017 14:55:54 +0000 (16:55 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 25 Jul 2017 14:55:54 +0000 (16:55 +0200)
examples/s4u/dht-chord/node.cpp
examples/s4u/dht-chord/s4u_dht-chord.tesh

index 184c1e3..b39c9f7 100644 (file)
@@ -120,8 +120,8 @@ void Node::notifyAndQuit()
     }
   }
 
-  if (pred_id_ != -1) {
-    // send the SUCCESSOR_LEAVING to our predecessor (only if I have one)
+  if (pred_id_ != -1 && pred_id_ != id_) {
+    // send the SUCCESSOR_LEAVING to our predecessor (only if I have one that is not me)
     ChordMessage* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
     succ_msg->request_id   = fingers_[0];
     succ_msg->answer_to    = mailbox_;
@@ -398,13 +398,10 @@ void Node::stabilize()
   XBT_DEBUG("Stabilizing node");
 
   // get the predecessor of my immediate successor
-  int candidate_id;
+  int candidate_id = pred_id_;
   int successor_id = fingers_[0];
-  if (successor_id != id_) {
+  if (successor_id != id_)
     candidate_id = remoteGetPredecessor(successor_id);
-  } else {
-    candidate_id = pred_id_;
-  }
 
   // this node is a candidate to become my new successor
   if (candidate_id != -1 && is_in_interval(candidate_id, id_ + 1, successor_id - 1)) {
index ebe7b47..f620d5a 100644 (file)
@@ -234,4 +234,4 @@ $ $SG_TEST_EXENV ${bindir:=.}/s4u_dht-chord$EXEEXT -nb_bits=3 ${srcdir:=.}/clust
 > [ 990.45356] (node@node-0.acme.org)    6  | 16728096
 > [ 990.45356] (node@node-0.acme.org) Predecessor: 42
 > [1040.45356] (node@node-0.acme.org) Well Guys! I Think it's time for me to leave ;)
-> [1090.46137] (maestro@) Simulated time: 1090.46
+> [1090.45356] (maestro@) Simulated time: 1090.45