Merge pull request #771 from milosgajdos83/peers-race
Remove data race; Unlock once done pruning/deleting
This commit is contained in:
commit
0abeb3f660
@ -30,8 +30,6 @@ type node struct {
|
|||||||
address string
|
address string
|
||||||
// peers are nodes with direct link to this node
|
// peers are nodes with direct link to this node
|
||||||
peers map[string]*node
|
peers map[string]*node
|
||||||
// edges store the node edges
|
|
||||||
edges map[string]map[string]*node
|
|
||||||
// network returns the node network
|
// network returns the node network
|
||||||
network Network
|
network Network
|
||||||
// lastSeen keeps track of node lifetime and updates
|
// lastSeen keeps track of node lifetime and updates
|
||||||
@ -196,7 +194,7 @@ func (n *node) GetPeerNode(id string) *node {
|
|||||||
// DeletePeerNode removes peer node from node topology
|
// DeletePeerNode removes peer node from node topology
|
||||||
func (n *node) DeletePeerNode(id string) error {
|
func (n *node) DeletePeerNode(id string) error {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
untilNoMorePeers := func(node *node) bool {
|
untilNoMorePeers := func(node *node) bool {
|
||||||
return node == nil
|
return node == nil
|
||||||
@ -223,7 +221,7 @@ func (n *node) DeletePeerNode(id string) error {
|
|||||||
// It returns a map of the the nodes that got pruned
|
// It returns a map of the the nodes that got pruned
|
||||||
func (n *node) PruneStalePeerNodes(pruneTime time.Duration) map[string]*node {
|
func (n *node) PruneStalePeerNodes(pruneTime time.Duration) map[string]*node {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
n.Unlock()
|
defer n.Unlock()
|
||||||
|
|
||||||
untilNoMorePeers := func(node *node) bool {
|
untilNoMorePeers := func(node *node) bool {
|
||||||
return node == nil
|
return node == nil
|
||||||
|
Loading…
Reference in New Issue
Block a user