redcon.Serve() never returns.
lithdew opened this issue · comments
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
}
}
Yes. This makes sense. I just pushed a fix that works as you describe.