Break big lock into some tiny locks
Don't involve code waiting for blocking channel in locked critical section because it has potential risk of hanging forever. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: 1326f0cba5f933674e23769de1385d3b0841e758 Component: engine
This commit is contained in:
@ -179,6 +179,13 @@ func (s *State) getExitCode() int {
|
||||
return res
|
||||
}
|
||||
|
||||
// SetRunningLocking locks container and sets it to "running"
|
||||
func (s *State) SetRunningLocking(pid int) {
|
||||
s.Lock()
|
||||
s.SetRunning(pid)
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
// SetRunning sets the state of the container to "running".
|
||||
func (s *State) SetRunning(pid int) {
|
||||
s.Error = ""
|
||||
@ -192,7 +199,7 @@ func (s *State) SetRunning(pid int) {
|
||||
s.waitChan = make(chan struct{})
|
||||
}
|
||||
|
||||
// SetStoppedLocking locks the container state is sets it to "stopped".
|
||||
// SetStoppedLocking locks the container state and sets it to "stopped".
|
||||
func (s *State) SetStoppedLocking(exitStatus *execdriver.ExitStatus) {
|
||||
s.Lock()
|
||||
s.SetStopped(exitStatus)
|
||||
|
||||
Reference in New Issue
Block a user