Explorar o código

server: not create new peer if exists

Yicheng Qin %!s(int64=11) %!d(string=hai) anos
pai
achega
01fdaea8a6
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  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 {
 		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
 }