Skip to content

Commit

Permalink
Fix panic
Browse files Browse the repository at this point in the history
Fix a panic. If the deleted item is the last one,
the ConnectingAddrs is out of range will panic.
So cann't assign the changed list to itself.

Signed-off-by: Jin Qing <[email protected]>
  • Loading branch information
superJinQing authored and dreamfly281 committed Jul 11, 2017
1 parent 6f15a40 commit 0c0e700
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ func (node *node) SetAddrInConnectingList(addr string) {
func (node *node) RemoveAddrInConnectingList(addr string) {
node.ConnectingNodes.Lock()
defer node.ConnectingNodes.Unlock()
addrs := []string{}
for i, a := range node.ConnectingAddrs {
if strings.Compare(a, addr) == 0 {
node.ConnectingAddrs = append(node.ConnectingAddrs[:i], node.ConnectingAddrs[i+1:]...)
addrs = append(node.ConnectingAddrs[:i], node.ConnectingAddrs[i+1:]...)
}
}
node.ConnectingAddrs = addrs
}

func (node *node) UpdateInfo(t time.Time, version uint32, services uint64,
Expand Down

0 comments on commit 0c0e700

Please sign in to comment.