Skip to content

Commit

Permalink
BACKPORT: Do not hold the peer map lock during the peerDBNetworkWalk
Browse files Browse the repository at this point in the history
Upstream reference: moby/libnetwork#1638
Upstream reference: moby#31016
BZ https://bugzilla.redhat.com/show_bug.cgi?id=1446184

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
  • Loading branch information
runcom committed Apr 27, 2017
1 parent 29d6f69 commit c14458a
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,30 @@ func (d *driver) peerDbWalk(f func(string, *peerKey, *peerEntry) bool) error {
func (d *driver) peerDbNetworkWalk(nid string, f func(*peerKey, *peerEntry) bool) error {
d.peerDb.Lock()
pMap, ok := d.peerDb.mp[nid]
d.peerDb.Unlock()

if !ok {
d.peerDb.Unlock()
return nil
}
d.peerDb.Unlock()

mp := map[string]peerEntry{}

pMap.Lock()
for pKeyStr, pEntry := range pMap.mp {
mp[pKeyStr] = pEntry
}
pMap.Unlock()

for pKeyStr, pEntry := range mp {
var pKey peerKey
if _, err := fmt.Sscan(pKeyStr, &pKey); err != nil {
log.Warnf("Peer key scan on network %s failed: %v", nid, err)
}

if f(&pKey, &pEntry) {
pMap.Unlock()
return nil
}
}
pMap.Unlock()

return nil
}
Expand Down

0 comments on commit c14458a

Please sign in to comment.