Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some potential pool leaks #1433

Merged
merged 1 commit into from Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion client.go
Expand Up @@ -983,6 +983,8 @@ var clientURLResponseChPool sync.Pool

func clientPostURL(dst []byte, url string, postArgs *Args, c clientDoer) (statusCode int, body []byte, err error) {
req := AcquireRequest()
defer ReleaseRequest(req)

req.Header.SetMethod(MethodPost)
req.Header.SetContentTypeBytes(strPostArgsContentType)
if postArgs != nil {
Expand All @@ -993,7 +995,6 @@ func clientPostURL(dst []byte, url string, postArgs *Args, c clientDoer) (status

statusCode, body, err = doRequestFollowRedirectsBuffer(req, dst, url, c)

ReleaseRequest(req)
return statusCode, body, err
}

Expand Down
3 changes: 2 additions & 1 deletion http.go
Expand Up @@ -1975,6 +1975,8 @@ func (resp *Response) String() string {

func getHTTPString(hw httpWriter) string {
w := bytebufferpool.Get()
defer bytebufferpool.Put(w)

bw := bufio.NewWriter(w)
if err := hw.Write(bw); err != nil {
return err.Error()
Expand All @@ -1983,7 +1985,6 @@ func getHTTPString(hw httpWriter) string {
return err.Error()
}
s := string(w.B)
bytebufferpool.Put(w)
return s
}

Expand Down