libnetwork/diagnostic: make DisableDiagnostic idempotent

Handle situations where the server is already stopped internally, instead
of requiring the caller to do this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-01-19 17:24:06 +01:00
parent 1e6449dfc7
commit e899092b25

View File

@@ -105,6 +105,9 @@ func (s *Server) EnableDiagnostic(ip string, port int) {
func (s *Server) DisableDiagnostic() {
s.mu.Lock()
defer s.mu.Unlock()
if !s.enable {
return
}
s.srv.Shutdown(context.Background()) //nolint:errcheck
s.srv = nil