Skip to content

Commit

Permalink
pillar/tests: Fix deadlock when Debug Server startup fails.
Browse files Browse the repository at this point in the history
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 <nikolay@zededa.com>
  • Loading branch information
OhmSpectator committed Oct 1, 2024
1 parent 8776e5d commit 7dd83ea
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/pillar/agentlog/agentlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 7dd83ea

Please sign in to comment.