Skip to content

Commit

Permalink
Merge pull request #2180 from ctelfer/fix-overlay-deadlock-regression
Browse files Browse the repository at this point in the history
Fix spurious deadlock in overlay driver
  • Loading branch information
Flavio Crisciani committed Jun 8, 2018
2 parents 90cb79c + 3755f80 commit 19279f0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/overlay/ov_network.go
Expand Up @@ -244,7 +244,15 @@ func (d *driver) DeleteNetwork(nid string) error {
}

d.Lock()
defer d.Unlock()
// Only perform a peer flush operation (if required) AFTER unlocking
// the driver lock to avoid deadlocking w/ the peerDB.
var doPeerFlush bool
defer func() {
d.Unlock()
if doPeerFlush {
d.peerFlush(nid)
}
}()

// This is similar to d.network(), but we need to keep holding the lock
// until we are done removing this network.
Expand All @@ -270,7 +278,7 @@ func (d *driver) DeleteNetwork(nid string) error {
}
}
// flush the peerDB entries
d.peerFlush(nid)
doPeerFlush = true
delete(d.networks, nid)

vnis, err := n.releaseVxlanID()
Expand Down

0 comments on commit 19279f0

Please sign in to comment.