Browse Source

server: not create new peer if exists

Yicheng Qin 11 years ago
parent
commit
01fdaea8a6
1 changed files with 3 additions and 1 deletions
  1. 3 1
      etcd/peer_hub.go

+ 3 - 1
etcd/peer_hub.go

@@ -109,7 +109,9 @@ func (h *peerHub) add(id int64, rawurl string) (*peer, error) {
 	if h.stopped {
 	if h.stopped {
 		return nil, fmt.Errorf("peerHub stopped")
 		return nil, fmt.Errorf("peerHub stopped")
 	}
 	}
-	h.peers[id] = newPeer(u.String(), h.c)
+	if _, ok := h.peers[id]; !ok {
+		h.peers[id] = newPeer(u.String(), h.c)
+	}
 	return h.peers[id], nil
 	return h.peers[id], nil
 }
 }