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

networkdb: fix data races in map access

Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
This commit is contained in:
Alexander Morozov 2016-08-05 13:54:17 -07:00
parent 0229451f3d
commit 392b089170
2 changed files with 6 additions and 1 deletions

View file

@ -221,9 +221,11 @@ func (nDB *NetworkDB) handleBulkSync(buf []byte) {
}
var nodeAddr net.IP
nDB.RLock()
if node, ok := nDB.nodes[bsm.NodeName]; ok {
nodeAddr = node.Addr
}
nDB.RUnlock()
if err := nDB.bulkSyncNode(bsm.Networks, bsm.NodeName, false); err != nil {
logrus.Errorf("Error in responding to bulk sync from node %s: %v", nodeAddr, err)

View file

@ -371,7 +371,10 @@ func (nDB *NetworkDB) JoinNetwork(nid string) error {
nodeNetworks[nid] = &network{id: nid, ltime: ltime}
nodeNetworks[nid].tableBroadcasts = &memberlist.TransmitLimitedQueue{
NumNodes: func() int {
return len(nDB.networkNodes[nid])
nDB.RLock()
num := len(nDB.networkNodes[nid])
nDB.RUnlock()
return num
},
RetransmitMult: 4,
}