Skip to content

Commit

Permalink
networkdb: fix race in deleteNetwork
Browse files Browse the repository at this point in the history
There are multiple places which reads from that slice(i.e. bulkSync).

Signed-off-by: Alexander Morozov <[email protected]>
  • Loading branch information
LK4D4 committed Oct 12, 2016
1 parent 848cd92 commit eacb25d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions networkdb/networkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ func (nDB *NetworkDB) addNetworkNode(nid string, nodeName string) {
// this
func (nDB *NetworkDB) deleteNetworkNode(nid string, nodeName string) {
nodes := nDB.networkNodes[nid]
for i, name := range nodes {
newNodes := make([]string, 0, len(nodes)-1)
for _, name := range nodes {
if name == nodeName {
nodes[i] = nodes[len(nodes)-1]
nodes = nodes[:len(nodes)-1]
break
continue
}
newNodes = append(newNodes, name)
}
nDB.networkNodes[nid] = nodes
nDB.networkNodes[nid] = newNodes
}

// findCommonnetworks find the networks that both this node and the
Expand Down

0 comments on commit eacb25d

Please sign in to comment.