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

redcon.Serve() never returns. #46

Open
lithdew opened this issue Jun 15, 2021 · 1 comment
Open

redcon.Serve() never returns. #46

lithdew opened this issue Jun 15, 2021 · 1 comment

Comments

@lithdew
Copy link

lithdew commented Jun 15, 2021

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
    }
}
tidwall added a commit that referenced this issue Mar 22, 2022
Server should return when the base Listener has been closed.

See #46
@tidwall
Copy link
Owner

tidwall commented Mar 22, 2022

Yes. This makes sense. I just pushed a fix that works as you describe.

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

No branches or pull requests

2 participants