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

Commit 9d765ef

Browse files
author
Ting Yuan
committed
Fix goroutine leak bug in DoDownloadTimeout
1 parent 1bb1d3e commit 9d765ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

dfget/core/downloader/downloader.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ func DoDownloadTimeout(downloader Downloader, timeout time.Duration) error {
5353

5454
var ch = make(chan error)
5555
go func() {
56-
ch <- downloader.Run(ctx)
56+
select {
57+
case <- ctx.Done():
58+
return
59+
case ch <- downloader.Run(ctx):
60+
return
61+
}
5762
}()
5863
defer cancel()
5964

0 commit comments

Comments
 (0)