Skip to content

Commit

Permalink
cmd/progress-bar: Fix data race in progress bar (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prnyself committed May 27, 2020
1 parent e77ea9d commit f3e0226
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/qsctl/taskutils/progress.go
Expand Up @@ -93,6 +93,7 @@ func init() {
// The data from noah is a map with taskID as key and its state as value.
// So we range the data and update relevant bar's progress.
func StartProgress(d time.Duration) {
wg.Add(1)
tc := time.NewTicker(d)
for {
select {
Expand Down Expand Up @@ -138,13 +139,14 @@ func StartProgress(d time.Duration) {

// WaitProgress wait the progress bar to complete
func WaitProgress() {
wg.Done()
pbPool.Wait()
}

// FinishProgress finish the progress bar and close the progress center
func FinishProgress() {
close(sigChan)
cancel()
close(sigChan)
}

// GetPBarByID returns the pbar's pointer with given taskID
Expand Down

0 comments on commit f3e0226

Please sign in to comment.