From 917a60409417db8344a86f5e89be9ab323b6224c Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 2 Apr 2018 08:17:21 -0600 Subject: [PATCH] httpserver: Ignore ErrServerClosed when closing server --- caddy.go | 2 +- caddyhttp/httpserver/server.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/caddy.go b/caddy.go index 917a5d069..2e3235441 100644 --- a/caddy.go +++ b/caddy.go @@ -798,7 +798,7 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res continue } if strings.Contains(err.Error(), "use of closed network connection") { - // this error is normal when closing the listener + // this error is normal when closing the listener; see https://github.com/golang/go/issues/4373 continue } log.Println(err) diff --git a/caddyhttp/httpserver/server.go b/caddyhttp/httpserver/server.go index 8028fce85..c3fbc6691 100644 --- a/caddyhttp/httpserver/server.go +++ b/caddyhttp/httpserver/server.go @@ -319,6 +319,9 @@ func (s *Server) Serve(ln net.Listener) error { } err := s.Server.Serve(ln) + if err == http.ErrServerClosed { + err = nil // not an error worth reporting since closing a server is intentional + } if s.quicServer != nil { s.quicServer.Close() }