From a15b6f21b8b99d7fb1886d268c859ed187ad5924 Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Mon, 13 Feb 2023 12:59:45 +0800 Subject: [PATCH] remove incorrect use of WaitGroup (#16596) --- cmd/batch-handlers.go | 3 --- cmd/bucket-replication.go | 7 ------- 2 files changed, 10 deletions(-) diff --git a/cmd/batch-handlers.go b/cmd/batch-handlers.go index 585d3835c..50e17a470 100644 --- a/cmd/batch-handlers.go +++ b/cmd/batch-handlers.go @@ -1029,7 +1029,6 @@ type BatchJobPool struct { mu sync.Mutex jobCh chan *BatchJobRequest workerKillCh chan struct{} - workerWg sync.WaitGroup workerSize int } @@ -1074,7 +1073,6 @@ func (j *BatchJobPool) AddWorker() { if j == nil { return } - defer j.workerWg.Done() for { select { case <-j.ctx.Done(): @@ -1110,7 +1108,6 @@ func (j *BatchJobPool) ResizeWorkers(n int) { for j.workerSize < n { j.workerSize++ - j.workerWg.Add(1) go j.AddWorker() } for j.workerSize > n { diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 5ce3aeb94..57841b116 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -1535,7 +1535,6 @@ type ReplicationPool struct { // workers: workers []chan ReplicationWorkerOperation existingWorkers chan ReplicationWorkerOperation - workerWg sync.WaitGroup // mrf: mrfWorkerKillCh chan struct{} @@ -1544,7 +1543,6 @@ type ReplicationPool struct { mrfStopCh chan struct{} mrfWorkerSize int saveStateCh chan struct{} - mrfWorkerWg sync.WaitGroup } // ReplicationWorkerOperation is a shared interface of replication operations. @@ -1607,7 +1605,6 @@ func NewReplicationPool(ctx context.Context, o ObjectLayer, opts replicationPool pool.ResizeWorkers(workers, 0) pool.ResizeFailedWorkers(failedWorkers) - pool.workerWg.Add(1) go pool.AddWorker(pool.existingWorkers, nil) go pool.resyncer.PersistToDisk(ctx, o) go pool.processMRF() @@ -1619,7 +1616,6 @@ func NewReplicationPool(ctx context.Context, o ObjectLayer, opts replicationPool // AddMRFWorker adds a pending/failed replication worker to handle requests that could not be queued // to the other workers func (p *ReplicationPool) AddMRFWorker() { - defer p.mrfWorkerWg.Done() for { select { case <-p.ctx.Done(): @@ -1646,7 +1642,6 @@ func (p *ReplicationPool) AddMRFWorker() { // An optional pointer to a tracker that will be atomically // incremented when operations are running can be provided. func (p *ReplicationPool) AddWorker(input <-chan ReplicationWorkerOperation, opTracker *int32) { - defer p.workerWg.Done() for { select { case <-p.ctx.Done(): @@ -1704,7 +1699,6 @@ func (p *ReplicationPool) ResizeWorkers(n, checkOld int) { input := make(chan ReplicationWorkerOperation, 10000) p.workers = append(p.workers, input) - p.workerWg.Add(1) go p.AddWorker(input, &p.activeWorkers) } for len(p.workers) > n { @@ -1748,7 +1742,6 @@ func (p *ReplicationPool) ResizeFailedWorkers(n int) { for p.mrfWorkerSize < n { p.mrfWorkerSize++ - p.mrfWorkerWg.Add(1) go p.AddMRFWorker() } for p.mrfWorkerSize > n {