mirror of
https://github.com/containers/podman.git
synced 2025-10-15 02:06:42 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user