libpod: race in WaitForConditionWithInterval()

There are multiple concurrent goroutinces which produce result and they
race agains each other, while producing different results.

This commit addresses at least a part of the problem - producing
different results for competing "sources".

Fixes: #25479

Signed-off-by: Yuri Timenkov <yuri@timenkov.pro>
This commit is contained in:
Yuri Timenkov
2025-03-06 12:40:43 +00:00
parent d0efd0e278
commit eed5f9ee4a

View File

@ -771,6 +771,12 @@ func (c *Container) WaitForConditionWithInterval(ctx context.Context, waitTimeou
// This allows callers to actually wait for the ctr to be removed.
if wantedStates[define.ContainerStateRemoving] &&
(errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved)) {
// check if the exit code was recorded in the db to return it
exitCode, err := c.runtime.state.GetContainerExitCode(c.ID())
if err == nil {
trySend(exitCode, nil)
}
trySend(-1, nil)
return
}