Skip to content

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

@odeke-em

Description

@odeke-em

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions