1
0
Fork 0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-05-10 08:36:08 +02:00

server: Avoid creating a new Listener after Close

This commit is contained in:
Adnan Maolood 2021-02-15 20:16:32 -05:00
parent f158bb5f1d
commit a05fa6d6bd

View File

@ -117,6 +117,10 @@ func (srv *Server) HandleFunc(pattern string, handler func(ResponseWriter, *Requ
// ListenAndServe always returns a non-nil error. After Shutdown or Close, the
// returned error is ErrServerClosed.
func (srv *Server) ListenAndServe() error {
if atomic.LoadInt32(&srv.done) == 1 {
return ErrServerClosed
}
addr := srv.Addr
if addr == "" {
addr = ":1965"