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:
commit
ffd13e32a8
1 changed files with 8 additions and 2 deletions
|
@ -112,14 +112,20 @@ func (nDB *NetworkDB) clusterInit() error {
|
|||
|
||||
nDB.networkBroadcasts = &memberlist.TransmitLimitedQueue{
|
||||
NumNodes: func() int {
|
||||
return len(nDB.nodes)
|
||||
nDB.RLock()
|
||||
num := len(nDB.nodes)
|
||||
nDB.RUnlock()
|
||||
return num
|
||||
},
|
||||
RetransmitMult: config.RetransmitMult,
|
||||
}
|
||||
|
||||
nDB.nodeBroadcasts = &memberlist.TransmitLimitedQueue{
|
||||
NumNodes: func() int {
|
||||
return len(nDB.nodes)
|
||||
nDB.RLock()
|
||||
num := len(nDB.nodes)
|
||||
nDB.RUnlock()
|
||||
return num
|
||||
},
|
||||
RetransmitMult: config.RetransmitMult,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue