1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix mutex copy

If we use peerMap as value, then we copy its mutex on
`pMap = d.peerDb.mp[nid]` and lock entirely different mutexes every
time.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-12-07 14:20:13 -08:00
parent 6769da8387
commit 46077fcfb1
2 changed files with 3 additions and 3 deletions

View file

@ -51,7 +51,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
d := &driver{
networks: networkTable{},
peerDb: peerNetworkMap{
mp: map[string]peerMap{},
mp: map[string]*peerMap{},
},
config: config,
}

View file

@ -26,7 +26,7 @@ type peerMap struct {
}
type peerNetworkMap struct {
mp map[string]peerMap
mp map[string]*peerMap
sync.Mutex
}
@ -138,7 +138,7 @@ func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask
d.peerDb.Lock()
pMap, ok := d.peerDb.mp[nid]
if !ok {
d.peerDb.mp[nid] = peerMap{
d.peerDb.mp[nid] = &peerMap{
mp: make(map[string]peerEntry),
}