1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-06-18 21:45:04 +08:00

fix #2368, which causes system lacked sufficient buffer space (#2372)

* fix #2368

* add CloseIdleConnections at WriteToFileMultiThreading
This commit is contained in:
Komei_DiSanXian 2023-08-23 12:59:53 +08:00 committed by GitHub
parent 977030e814
commit da9f03fa47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,6 +137,7 @@ func (r Request) Bytes() ([]byte, error) {
return nil, err return nil, err
} }
defer rd.Close() defer rd.Close()
defer r.client().CloseIdleConnections()
return io.ReadAll(rd) return io.ReadAll(rd)
} }
@ -147,6 +148,7 @@ func (r Request) JSON() (gjson.Result, error) {
return gjson.Result{}, err return gjson.Result{}, err
} }
defer rd.Close() defer rd.Close()
defer r.client().CloseIdleConnections()
var sb strings.Builder var sb strings.Builder
_, err = io.Copy(&sb, rd) _, err = io.Copy(&sb, rd)
@ -174,6 +176,7 @@ func (r Request) WriteToFile(path string) error {
return err return err
} }
defer rd.Close() defer rd.Close()
defer r.client().CloseIdleConnections()
return writeToFile(rd, path) return writeToFile(rd, path)
} }
@ -183,6 +186,7 @@ func (r Request) WriteToFileMultiThreading(path string, thread int) error {
return r.WriteToFile(path) return r.WriteToFile(path)
} }
defer r.client().CloseIdleConnections()
limit := r.Limit limit := r.Limit
type BlockMetaData struct { type BlockMetaData struct {
BeginOffset int64 BeginOffset int64