From c3fe04f2e1e2d11a18e39780f23a6b0fcc1b26d0 Mon Sep 17 00:00:00 2001 From: Yilun Date: Wed, 12 Sep 2018 22:51:28 -0700 Subject: [PATCH] Prevent node from adding self to successor list when joining Signed-off-by: Yilun --- net/chord/chord.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/chord/chord.go b/net/chord/chord.go index b2c8d26e5..6c31c44b5 100644 --- a/net/chord/chord.go +++ b/net/chord/chord.go @@ -216,8 +216,13 @@ func Join(conf *Config, trans Transport, existing string) (*Ring, error) { } // Assign the successors + skip := 0 for idx, s := range succs { - vn.successors[idx] = s + if s != nil && s.String() != vn.String() { + vn.successors[idx-skip] = s + } else { + skip++ + } } }