Skip to content

Commit

Permalink
Fix possible concurrency bug, fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zytek committed Dec 8, 2020
1 parent e6b038b commit b8e29de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ func (j *job) copyObject(key string) {

func (j *job) runConsumers(wg *sync.WaitGroup) {
for i := 0; i < cap(j.copyChan); i++ {
wg.Add(1)
go func() {
wg.Add(1)
for key := range j.copyChan {
j.copyObject(key)
for k := range j.copyChan {
j.copyObject(k)
}
wg.Done()
}()
Expand All @@ -96,6 +96,7 @@ func (j *job) copy() {
}
close(j.copyChan)
wg.Wait()
j.status()
}

func (j *job) prepare() {
Expand Down Expand Up @@ -148,7 +149,6 @@ func (j *job) status() {
func (j *job) Start() {
j.prepare()
log.Println(j.name(), "starting, must copy", len(j.copyList), "new objects (", bytes(j.copyTotalSize), ")")
log.Println(j.name(), "displaying status updates every 1 sec")
go func() {
for {
time.Sleep(time.Second)
Expand Down

0 comments on commit b8e29de

Please sign in to comment.