libpod: wait for healthy on main thread

wait for the healthy status on the thread where the container lock is
held.  Otherwise, if it is performed from a go routine, a different
thread is used (since the runtime.LockOSThread() call doesn't have any
effect), causing pthread_mutex_unlock() to fail with EPERM.

Closes: https://github.com/containers/podman/issues/22651

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2024-05-09 16:08:55 +02:00
parent 87bd77538e
commit b06c58b4a5
5 changed files with 50 additions and 19 deletions

View File

@ -115,7 +115,10 @@ func (c *Container) Start(ctx context.Context, recursive bool) (finalErr error)
}
// Start the container
return c.start(ctx)
if err := c.start(); err != nil {
return err
}
return c.waitForHealthy(ctx)
}
// Update updates the given container.
@ -194,6 +197,9 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *define.AttachSt
opts.Start = true
opts.Started = startedChan
// attach and start the container on a different thread. waitForHealthy must
// be done later, as it requires to run on the same thread that holds the lock
// for the container.
if err := c.ociRuntime.Attach(c, opts); err != nil {
attachChan <- err
}
@ -207,7 +213,7 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *define.AttachSt
c.newContainerEvent(events.Attach)
}
return attachChan, nil
return attachChan, c.waitForHealthy(ctx)
}
// RestartWithTimeout restarts a running container and takes a given timeout in uint