Skip to content

Commit

Permalink
avoid concurrent join
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Oct 23, 2018
1 parent c7ca4fb commit cb475a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func PrepareJoinCluster(cfg *Config) error {

existed := false
for _, m := range listResp.Members {
if len(m.Name) == 0 {
return errors.New("exsist a member that the join is not completed")
}
if m.Name == cfg.Name {
existed = true
}
Expand Down Expand Up @@ -154,6 +157,9 @@ func PrepareJoinCluster(cfg *Config) error {
if memb.ID == addResp.Member.ID {
n = cfg.Name
}
if len(n) == 0 {
return errors.New("exsist a member that the join is not completed")
}
for _, m := range memb.PeerURLs {
pds = append(pds, fmt.Sprintf("%s=%s", n, m))
}
Expand Down

0 comments on commit cb475a5

Please sign in to comment.