From 0739b996ebdbecc89e8f8e394fa91e3978811cf0 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 25 Jul 2017 16:55:54 +0200 Subject: [PATCH] partial leak plug in chord --- examples/s4u/dht-chord/node.cpp | 11 ++++------- examples/s4u/dht-chord/s4u_dht-chord.tesh | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/s4u/dht-chord/node.cpp b/examples/s4u/dht-chord/node.cpp index 184c1e3910..b39c9f749d 100644 --- a/examples/s4u/dht-chord/node.cpp +++ b/examples/s4u/dht-chord/node.cpp @@ -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)) { diff --git a/examples/s4u/dht-chord/s4u_dht-chord.tesh b/examples/s4u/dht-chord/s4u_dht-chord.tesh index ebe7b47adc..f620d5a961 100644 --- a/examples/s4u/dht-chord/s4u_dht-chord.tesh +++ b/examples/s4u/dht-chord/s4u_dht-chord.tesh @@ -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 -- 2.20.1