From 1a660f7d91aed3f6872fd2a07c7eab482d52e02b Mon Sep 17 00:00:00 2001 From: Gustavo Chain Date: Sat, 21 Sep 2024 09:12:25 -0300 Subject: [PATCH] fix leaks Missing descriptor closes has been added. --- internal/server/health_check.go | 1 + internal/server/router.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/server/health_check.go b/internal/server/health_check.go index 4cadf28..c22168a 100644 --- a/internal/server/health_check.go +++ b/internal/server/health_check.go @@ -75,6 +75,7 @@ func (hc *HealthCheck) check() { hc.consumer.HealthCheckCompleted(false) return } + defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode > 299 { slog.Info("Healthcheck failed", "status", resp.StatusCode) diff --git a/internal/server/router.go b/internal/server/router.go index bc9fd28..f279b61 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -54,6 +54,7 @@ func (r *Router) RestoreLastSavedState() error { slog.Error("Failed to restore saved state", "path", r.statePath, "error", err) return err } + defer f.Close() var services []*Service err = json.NewDecoder(f).Decode(&services)