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:
parent
6769da8387
commit
46077fcfb1
2 changed files with 3 additions and 3 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue