Skip to content

redcon.Serve() never returns. #46

@lithdew

Description

@lithdew

redcon.serve() only returns if (*Server).done is ever set to true, which is only possible if (*Server).Close() is called.

Given that the use of redcon.Serve(ln net.Listener, ...) unlike any of the other methods exposed in the package assumes that the user is not keeping around a *redcon.Server instance, it wouldn't be possible for the user to force redcon.Serve() to ever return, which is behavior that is desired for e.g. graceful shutdown.

Rather than ignoring errors from net.Listener.Accept() in redcon.serve() unless (*Server).done is set to true, what about breaking early from redcon.serve()'s accept loop if an error is returned by net.Listener.Accept() which indicates that the listener is closed?

For example:

lnconn, err := s.ln.Accept()
if err != nil {
    // .....
    if errors.Is(err, net.ErrClosed) {
        return nil
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions