Revert "use state machine management for exec.Pid()"
This reverts commit bbc2a995f9
.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
f7f24e2f3a
commit
9777d76890
@ -69,7 +69,3 @@ func (s *deletedState) SetExited(status int) {
|
|||||||
func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
|
||||||
return nil, errors.Errorf("cannot exec in a deleted state")
|
return nil, errors.Errorf("cannot exec in a deleted state")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *deletedState) Pid() int {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
@ -69,10 +69,8 @@ func (e *execProcess) ID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *execProcess) Pid() int {
|
func (e *execProcess) Pid() int {
|
||||||
return e.execState.Pid()
|
e.mu.Lock()
|
||||||
}
|
defer e.mu.Unlock()
|
||||||
|
|
||||||
func (e *execProcess) pidv() int {
|
|
||||||
return e.pid
|
return e.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ type execState interface {
|
|||||||
Delete(context.Context) error
|
Delete(context.Context) error
|
||||||
Kill(context.Context, uint32, bool) error
|
Kill(context.Context, uint32, bool) error
|
||||||
SetExited(int)
|
SetExited(int)
|
||||||
Pid() int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type execCreatedState struct {
|
type execCreatedState struct {
|
||||||
@ -83,12 +82,6 @@ func (s *execCreatedState) SetExited(status int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *execCreatedState) Pid() int {
|
|
||||||
s.p.mu.Lock()
|
|
||||||
defer s.p.mu.Unlock()
|
|
||||||
return s.p.pidv()
|
|
||||||
}
|
|
||||||
|
|
||||||
type execRunningState struct {
|
type execRunningState struct {
|
||||||
p *execProcess
|
p *execProcess
|
||||||
}
|
}
|
||||||
@ -127,12 +120,6 @@ func (s *execRunningState) SetExited(status int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *execRunningState) Pid() int {
|
|
||||||
s.p.mu.Lock()
|
|
||||||
defer s.p.mu.Unlock()
|
|
||||||
return s.p.pidv()
|
|
||||||
}
|
|
||||||
|
|
||||||
type execStoppedState struct {
|
type execStoppedState struct {
|
||||||
p *execProcess
|
p *execProcess
|
||||||
}
|
}
|
||||||
@ -170,7 +157,3 @@ func (s *execStoppedState) Kill(ctx context.Context, sig uint32, all bool) error
|
|||||||
func (s *execStoppedState) SetExited(status int) {
|
func (s *execStoppedState) SetExited(status int) {
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *execStoppedState) Pid() int {
|
|
||||||
return s.p.pidv()
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user