Skip to content

Commit

Permalink
fix #2368, which causes system lacked sufficient buffer space (#2372)
Browse files Browse the repository at this point in the history
* fix #2368

* add CloseIdleConnections at WriteToFileMultiThreading
  • Loading branch information
KomeiDiSanXian authored Aug 23, 2023
1 parent 977030e commit da9f03f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (r Request) Bytes() ([]byte, error) {
return nil, err
}
defer rd.Close()
defer r.client().CloseIdleConnections()
return io.ReadAll(rd)
}

Expand All @@ -147,6 +148,7 @@ func (r Request) JSON() (gjson.Result, error) {
return gjson.Result{}, err
}
defer rd.Close()
defer r.client().CloseIdleConnections()

var sb strings.Builder
_, err = io.Copy(&sb, rd)
Expand Down Expand Up @@ -174,6 +176,7 @@ func (r Request) WriteToFile(path string) error {
return err
}
defer rd.Close()
defer r.client().CloseIdleConnections()
return writeToFile(rd, path)
}

Expand All @@ -183,6 +186,7 @@ func (r Request) WriteToFileMultiThreading(path string, thread int) error {
return r.WriteToFile(path)
}

defer r.client().CloseIdleConnections()
limit := r.Limit
type BlockMetaData struct {
BeginOffset int64
Expand Down

0 comments on commit da9f03f

Please sign in to comment.