diff options
author | Mohammed Al Sahaf <[email protected]> | 2023-11-01 20:17:02 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-01 13:17:02 -0400 |
commit | 3b3d67871446ee6bf1921938ef0f16b6112c7ceb (patch) | |
tree | e31759acaecdf6fccb8b410cd9d00b011f9d8dbf /modules/caddyhttp/server.go | |
parent | ee358550e4235c5ce9939dc57a8927ba2cd87657 (diff) | |
download | caddy-3b3d67871446ee6bf1921938ef0f16b6112c7ceb.tar.gz caddy-3b3d67871446ee6bf1921938ef0f16b6112c7ceb.zip |
Revert "caddyhttp: Use sync.Pool to reduce lengthReader allocations (#5848)" (#5924)
Diffstat (limited to 'modules/caddyhttp/server.go')
-rw-r--r-- | modules/caddyhttp/server.go | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index b98619189..d060738f1 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -318,8 +318,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { // so we can track the number of bytes read from it var bodyReader *lengthReader if r.Body != nil { - bodyReader = getLengthReader(r.Body) - defer putLengthReader(bodyReader) + bodyReader = &lengthReader{Source: r.Body} r.Body = bodyReader } @@ -903,24 +902,6 @@ type lengthReader struct { Length int } -var lengthReaderPool = sync.Pool{ - New: func() interface{} { - return &lengthReader{} - }, -} - -func getLengthReader(source io.ReadCloser) *lengthReader { - reader := lengthReaderPool.Get().(*lengthReader) - reader.Source = source - return reader -} - -func putLengthReader(reader *lengthReader) { - reader.Source = nil - reader.Length = 0 - lengthReaderPool.Put(reader) -} - func (r *lengthReader) Read(b []byte) (int, error) { n, err := r.Source.Read(b) r.Length += n |