Stop holding client container lock during shutdown
Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
parent
fd5f9d7941
commit
b819ffdb20
1 changed files with 10 additions and 10 deletions
|
@ -201,9 +201,18 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
|
||||||
logrus.Debugln("libcontainerd: waitExit() on pid", process.systemPid)
|
logrus.Debugln("libcontainerd: waitExit() on pid", process.systemPid)
|
||||||
|
|
||||||
exitCode := ctr.waitProcessExitCode(process)
|
exitCode := ctr.waitProcessExitCode(process)
|
||||||
// Lock the container while shutting down
|
// Lock the container while removing the process/container from the list
|
||||||
ctr.client.lock(ctr.containerID)
|
ctr.client.lock(ctr.containerID)
|
||||||
|
|
||||||
|
if !isFirstProcessToStart {
|
||||||
|
ctr.cleanProcess(process.friendlyName)
|
||||||
|
} else {
|
||||||
|
ctr.client.deleteContainer(ctr.containerID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock here so other threads are unblocked
|
||||||
|
ctr.client.unlock(ctr.containerID)
|
||||||
|
|
||||||
// Assume the container has exited
|
// Assume the container has exited
|
||||||
si := StateInfo{
|
si := StateInfo{
|
||||||
CommonStateInfo: CommonStateInfo{
|
CommonStateInfo: CommonStateInfo{
|
||||||
|
@ -218,7 +227,6 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
|
||||||
// But it could have been an exec'd process which exited
|
// But it could have been an exec'd process which exited
|
||||||
if !isFirstProcessToStart {
|
if !isFirstProcessToStart {
|
||||||
si.State = StateExitProcess
|
si.State = StateExitProcess
|
||||||
ctr.cleanProcess(process.friendlyName)
|
|
||||||
} else {
|
} else {
|
||||||
updatePending, err := ctr.hcsContainer.HasPendingUpdates()
|
updatePending, err := ctr.hcsContainer.HasPendingUpdates()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -236,20 +244,12 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
|
||||||
if err := ctr.hcsContainer.Close(); err != nil {
|
if err := ctr.hcsContainer.Close(); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove process from list if we have exited
|
|
||||||
if si.State == StateExit {
|
|
||||||
ctr.client.deleteContainer(ctr.containerID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := process.hcsProcess.Close(); err != nil {
|
if err := process.hcsProcess.Close(); err != nil {
|
||||||
logrus.Errorf("libcontainerd: hcsProcess.Close(): %v", err)
|
logrus.Errorf("libcontainerd: hcsProcess.Close(): %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlock here before we call back into the daemon to update state
|
|
||||||
ctr.client.unlock(ctr.containerID)
|
|
||||||
|
|
||||||
// Call into the backend to notify it of the state change.
|
// Call into the backend to notify it of the state change.
|
||||||
logrus.Debugf("libcontainerd: waitExit() calling backend.StateChanged %+v", si)
|
logrus.Debugf("libcontainerd: waitExit() calling backend.StateChanged %+v", si)
|
||||||
if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil {
|
if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue