Fix misuse of sync.Pool (#76)

This commit is contained in:
單dar 于ɦʷa 2020-06-21 01:21:32 +08:00 committed by GitHub
parent e92fe979d0
commit 03a7df4bf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -579,6 +579,7 @@ func dualStream(target net.Conn, clientReader io.ReadCloser, clientWriter io.Wri
buf := bufferPool.Get().([]byte)
buf = buf[0:cap(buf)]
_, _err := flushingIoCopy(w, r, buf)
bufferPool.Put(buf)
if cw, ok := w.(closeWriter); ok {
cw.CloseWrite()
}
@ -642,6 +643,7 @@ func forwardResponse(w http.ResponseWriter, response *http.Response) error {
buf := bufferPool.Get().([]byte)
buf = buf[0:cap(buf)]
_, err := io.CopyBuffer(w, response.Body, buf)
bufferPool.Put(buf)
return err
}