Skip to content

Commit

Permalink
Fix misuse of sync.Pool (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
darhwa authored Jun 20, 2020
1 parent e92fe97 commit 03a7df4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions forwardproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 03a7df4

Please sign in to comment.