Fix misuse of sync.Pool (#76)
This commit is contained in:
parent
e92fe979d0
commit
03a7df4bf7
1 changed files with 2 additions and 0 deletions
|
|
@ -579,6 +579,7 @@ func dualStream(target net.Conn, clientReader io.ReadCloser, clientWriter io.Wri
|
||||||
buf := bufferPool.Get().([]byte)
|
buf := bufferPool.Get().([]byte)
|
||||||
buf = buf[0:cap(buf)]
|
buf = buf[0:cap(buf)]
|
||||||
_, _err := flushingIoCopy(w, r, buf)
|
_, _err := flushingIoCopy(w, r, buf)
|
||||||
|
bufferPool.Put(buf)
|
||||||
if cw, ok := w.(closeWriter); ok {
|
if cw, ok := w.(closeWriter); ok {
|
||||||
cw.CloseWrite()
|
cw.CloseWrite()
|
||||||
}
|
}
|
||||||
|
|
@ -642,6 +643,7 @@ func forwardResponse(w http.ResponseWriter, response *http.Response) error {
|
||||||
buf := bufferPool.Get().([]byte)
|
buf := bufferPool.Get().([]byte)
|
||||||
buf = buf[0:cap(buf)]
|
buf = buf[0:cap(buf)]
|
||||||
_, err := io.CopyBuffer(w, response.Body, buf)
|
_, err := io.CopyBuffer(w, response.Body, buf)
|
||||||
|
bufferPool.Put(buf)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue