From 7dd83ea9d01ea26b50abd387faed4de33f76dd5b Mon Sep 17 00:00:00 2001 From: Nikolay Martyanov Date: Tue, 1 Oct 2024 15:58:42 +0200 Subject: [PATCH] pillar/tests: Fix deadlock when Debug Server startup fails. In `startIntegratedPSICollectorAPI`, if the server does not start within 10 seconds, the function returns an error without unlocking `psiServerMutex`. This oversight leads to a deadlock in subsequent tests that attempt to acquire the same mutex. This commit adds `psiServerMutex.Unlock()` before returning the error to ensure that the mutex is properly released even when the server fails to start. Signed-off-by: Nikolay Martyanov --- pkg/pillar/agentlog/agentlog_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/pillar/agentlog/agentlog_test.go b/pkg/pillar/agentlog/agentlog_test.go index 0585dc3c82..0eaac1180d 100644 --- a/pkg/pillar/agentlog/agentlog_test.go +++ b/pkg/pillar/agentlog/agentlog_test.go @@ -422,6 +422,7 @@ func startIntegratedPSICollectorAPI() (cancel context.CancelFunc, err error) { time.Sleep(100 * time.Millisecond) } if !started { + psiServerMutex.Unlock() return nil, fmt.Errorf("could not start the server in 10 seconds") } ctx, cancel := context.WithCancel(context.Background())