avoid deadlock

This commit is contained in:
Konstantin Lebedev 2022-07-21 17:15:10 +05:00
parent 03a0936556
commit 3c42814b58

View file

@ -368,8 +368,16 @@ func (ms *MasterServer) OnPeerUpdate(update *master_pb.ClusterNodeUpdate, startF
}
}
ms.onPeerUpdateLock.RLock()
if len(ms.onPeerUpdateDoneCns) > 0 {
for _, onPeerUpdateDoneCn := range ms.onPeerUpdateDoneCns {
isGtZero := len(ms.onPeerUpdateDoneCns) > 0
ms.onPeerUpdateLock.RUnlock()
if isGtZero {
var chanPtrs []*chan string
ms.onPeerUpdateLock.RLock()
for _, cn := range ms.onPeerUpdateDoneCns {
chanPtrs = append(chanPtrs, cn)
}
ms.onPeerUpdateLock.RUnlock()
for _, onPeerUpdateDoneCn := range chanPtrs {
*onPeerUpdateDoneCn <- peerName
}
}