Browse Source

onPeerUpdateGoroutineCount use int32

pull/3338/head
Konstantin Lebedev 2 years ago
parent
commit
7875470e74
  1. 8
      weed/server/master_server.go

8
weed/server/master_server.go

@ -67,7 +67,7 @@ type MasterServer struct {
boundedLeaderChan chan int boundedLeaderChan chan int
onPeerUpdateDoneCn chan string onPeerUpdateDoneCn chan string
onPeerUpdateGoroutineCount uint32
onPeerUpdateGoroutineCount int32
// notifying clients // notifying clients
clientChansLock sync.RWMutex clientChansLock sync.RWMutex
@ -367,16 +367,16 @@ func (ms *MasterServer) OnPeerUpdate(update *master_pb.ClusterNodeUpdate, startF
hashicorpRaft.ServerAddress(peerAddress.ToGrpcAddress()), 0, 0) hashicorpRaft.ServerAddress(peerAddress.ToGrpcAddress()), 0, 0)
} }
} }
if atomic.LoadUint32(&ms.onPeerUpdateGoroutineCount) > 0 {
if atomic.LoadInt32(&ms.onPeerUpdateGoroutineCount) > 0 {
ms.onPeerUpdateDoneCn <- peerName ms.onPeerUpdateDoneCn <- peerName
} }
} else if isLeader { } else if isLeader {
go func(peerName string) { go func(peerName string) {
raftServerRemovalTimeAfter := time.After(RaftServerRemovalTime) raftServerRemovalTimeAfter := time.After(RaftServerRemovalTime)
raftServerPingTicker := time.NewTicker(5 * time.Minute) raftServerPingTicker := time.NewTicker(5 * time.Minute)
atomic.AddUint32(&ms.onPeerUpdateGoroutineCount, 1)
atomic.AddInt32(&ms.onPeerUpdateGoroutineCount, 1)
defer func() { defer func() {
atomic.AddUint32(&ms.onPeerUpdateGoroutineCount, -1)
atomic.AddInt32(&ms.onPeerUpdateGoroutineCount, -1)
}() }()
for { for {
select { select {

Loading…
Cancel
Save