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

net/http/server.go var pool in function newBufioWriterSize(io.Writer, int) *bufio.Writer Get return nil #39673

Closed
snowdusk opened this issue Jun 18, 2020 · 2 comments

Comments

@snowdusk
Copy link

What version of Go are you using (go version)?

$ go version
1.15beta1

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

What did you expect to see?

Because there is no New function supplied for bufioWriter2kPool and bufioWriter4kPool, every time pool Get return nil.
`
func newBufioWriterSize(w io.Writer, size int) *bufio.Writer {

    pool := bufioWriterPool(size)  // should  delete or supply New func
    if pool != nil {
            if v := pool.Get(); v != nil {
                    bw := v.(*bufio.Writer)
                    bw.Reset(w)
                    return bw
            }
    }
    return bufio.NewWriterSize(w, size)

}
`

What did you see instead?

@andybons
Copy link
Member

Duplicate of #39648

Unless you have found a bug, please use one of the other forums mentioned in #39648 for asking a question instead of the issue tracker. Thanks.

@davecheney
Copy link
Contributor

@wangsong93 the buffer pools are lazily initialised by filling the pool with entries in putBufioWriter rather than using a New function. This is because the bufio.Writer's returned from the pool must be a specific size which is best handled in newBufioWriterSize

@golang golang locked and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants