From 9777d76890e9a27260828a68455e743ac1a95c3e Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Thu, 31 Jan 2019 18:59:29 -0800 Subject: [PATCH] Revert "use state machine management for exec.Pid()" This reverts commit bbc2a995f97c84670ba47126a2bbba1b302c4211. Signed-off-by: Lantao Liu --- runtime/v1/linux/proc/deleted_state.go | 4 ---- runtime/v1/linux/proc/exec.go | 6 ++---- runtime/v1/linux/proc/exec_state.go | 17 ----------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/runtime/v1/linux/proc/deleted_state.go b/runtime/v1/linux/proc/deleted_state.go index bc9aefb7f..ab89c3ecb 100644 --- a/runtime/v1/linux/proc/deleted_state.go +++ b/runtime/v1/linux/proc/deleted_state.go @@ -69,7 +69,3 @@ func (s *deletedState) SetExited(status int) { func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) { return nil, errors.Errorf("cannot exec in a deleted state") } - -func (s *deletedState) Pid() int { - return -1 -} diff --git a/runtime/v1/linux/proc/exec.go b/runtime/v1/linux/proc/exec.go index 171ece030..d71eca128 100644 --- a/runtime/v1/linux/proc/exec.go +++ b/runtime/v1/linux/proc/exec.go @@ -69,10 +69,8 @@ func (e *execProcess) ID() string { } func (e *execProcess) Pid() int { - return e.execState.Pid() -} - -func (e *execProcess) pidv() int { + e.mu.Lock() + defer e.mu.Unlock() return e.pid } diff --git a/runtime/v1/linux/proc/exec_state.go b/runtime/v1/linux/proc/exec_state.go index 0e0bc3fcf..12489501b 100644 --- a/runtime/v1/linux/proc/exec_state.go +++ b/runtime/v1/linux/proc/exec_state.go @@ -31,7 +31,6 @@ type execState interface { Delete(context.Context) error Kill(context.Context, uint32, bool) error SetExited(int) - Pid() int } 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 { 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 { p *execProcess } @@ -170,7 +157,3 @@ func (s *execStoppedState) Kill(ctx context.Context, sig uint32, all bool) error func (s *execStoppedState) SetExited(status int) { // no op } - -func (s *execStoppedState) Pid() int { - return s.p.pidv() -}