Skip to content

Commit 6228274

Browse files
Alex Couture-Beilalexcb
authored andcommitted
pullprogress data race
There's a context which gets recreated via ctx = context.TODO() which races with go func() { <-ctx.Done() ticker.Stop() }() To prevent this, the original context reference should be passed in via an arg. Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
1 parent a7789ee commit 6228274

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

util/pull/pullprogress/progress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ func trackProgress(ctx context.Context, desc ocispecs.Descriptor, manager PullMa
9393

9494
ticker := time.NewTicker(150 * time.Millisecond)
9595
defer ticker.Stop()
96-
go func() {
96+
go func(ctx context.Context) {
9797
<-ctx.Done()
9898
ticker.Stop()
99-
}()
99+
}(ctx)
100100

101101
pw, _, _ := progress.NewFromContext(ctx)
102102
defer pw.Close()

0 commit comments

Comments
 (0)