vfs: fix file leaks with --vfs-cache-mode full and --buffer-size 0
Before this change using --vfs-cache-mode full and --buffer-size 0 together caused the vfs downloader to open more and more downloaders. This is fixed by introducing a minimum size of 1M for the window to look for an existing downloader. Fixes #4892
This commit is contained in:
parent
757e696a6b
commit
b80d498304
1 changed files with 8 additions and 0 deletions
|
@ -26,6 +26,9 @@ const (
|
|||
backgroundKickerInterval = 5 * time.Second
|
||||
// maximum number of errors before declaring dead
|
||||
maxErrorCount = 10
|
||||
// If a downloader is within this range or --buffer-size
|
||||
// whichever is the larger, we will reuse the downloader
|
||||
minWindow = 1024 * 1024
|
||||
)
|
||||
|
||||
// Item is the interface that an item to download must obey
|
||||
|
@ -327,6 +330,11 @@ func (dls *Downloaders) _ensureDownloader(r ranges.Range) (err error) {
|
|||
r.Size = 0
|
||||
}
|
||||
|
||||
// If buffer size is less than minWindow then make it that
|
||||
if window < minWindow {
|
||||
window = minWindow
|
||||
}
|
||||
|
||||
var dl *downloader
|
||||
// Look through downloaders to find one in range
|
||||
// If there isn't one then start a new one
|
||||
|
|
Loading…
Reference in a new issue