Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Fix goroutine leak bug in DoDownloadTimeout
Browse files Browse the repository at this point in the history
Signed-off-by: Ting Yuan <[email protected]>
  • Loading branch information
Ting Yuan committed Nov 1, 2021
1 parent 1bb1d3e commit aa4e2c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dfget/core/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ func DoDownloadTimeout(downloader Downloader, timeout time.Duration) error {

var ch = make(chan error)
go func() {
ch <- downloader.Run(ctx)
select {
case <- ctx.Done():
return
case ch <- downloader.Run(ctx):
return
}
}()
defer cancel()

Expand Down

0 comments on commit aa4e2c3

Please sign in to comment.