Skip to content

Commit

Permalink
Merge pull request #1503 from LK4D4/fix_race_delete_network
Browse files Browse the repository at this point in the history
networkdb: fix race in deleteNetwork
  • Loading branch information
Santhosh Manohar authored Oct 13, 2016
2 parents 5148486 + eacb25d commit ebfa69e
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 ebfa69e

Please sign in to comment.