From e899092b254d2516efe533228ebff4dd6dca8a9a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 19 Jan 2025 17:24:06 +0100 Subject: [PATCH] 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 --- libnetwork/diagnostic/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libnetwork/diagnostic/server.go b/libnetwork/diagnostic/server.go index cdd097c3c0..f95ae6f3d4 100644 --- a/libnetwork/diagnostic/server.go +++ b/libnetwork/diagnostic/server.go @@ -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