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

remotedb/grpcdb: a net.Listener leaks if ListenAndServe's NewServer or srv.Serve errors in any way #268

Open
odeke-em opened this issue Jun 28, 2022 · 0 comments

Comments

@odeke-em
Copy link

If we examine the code in here

func ListenAndServe(addr, cert, key string, opts ...grpc.ServerOption) error {
ln, err := net.Listen("tcp", addr)
if err != nil {
return err
}
srv, err := NewServer(cert, key, opts...)
if err != nil {
return err
}
return srv.Serve(ln)

we notice that after we invoke net.Listen there is a listener in there that'll be bound to an address, but if any error occurs it won't be released at all

odeke-em added a commit to orijtech/tm-db that referenced this issue Jun 28, 2022
Uses Go's named return value feature to properly check and
ensure that if any error is encountered, that we properly
invoke .Close for the bound net listener inside of ListenAndServe.

Fixes tendermint#268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant