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

Merge pull request #1492 from LK4D4/fix_nodes_race

networkdb: fix race in access to nodes len
This commit is contained in:
Jana Radhakrishnan 2016-10-04 12:52:52 -07:00 committed by GitHub
commit ffd13e32a8

View file

@ -112,14 +112,20 @@ func (nDB *NetworkDB) clusterInit() error {
nDB.networkBroadcasts = &memberlist.TransmitLimitedQueue{ nDB.networkBroadcasts = &memberlist.TransmitLimitedQueue{
NumNodes: func() int { NumNodes: func() int {
return len(nDB.nodes) nDB.RLock()
num := len(nDB.nodes)
nDB.RUnlock()
return num
}, },
RetransmitMult: config.RetransmitMult, RetransmitMult: config.RetransmitMult,
} }
nDB.nodeBroadcasts = &memberlist.TransmitLimitedQueue{ nDB.nodeBroadcasts = &memberlist.TransmitLimitedQueue{
NumNodes: func() int { NumNodes: func() int {
return len(nDB.nodes) nDB.RLock()
num := len(nDB.nodes)
nDB.RUnlock()
return num
}, },
RetransmitMult: config.RetransmitMult, RetransmitMult: config.RetransmitMult,
} }