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

@snowdusk snowdusk commented Jun 18, 2020

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

@andybons andybons commented Jun 18, 2020

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.

@andybons andybons closed this Jun 18, 2020
@davecheney
Copy link
Contributor

@davecheney davecheney commented Jun 18, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.