-
Notifications
You must be signed in to change notification settings - Fork 167
Open
Description
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
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels