Skip to content

Commit 9777d76

Browse files
committed
Revert "use state machine management for exec.Pid()"
This reverts commit bbc2a99. Signed-off-by: Lantao Liu <[email protected]>
1 parent f7f24e2 commit 9777d76

3 files changed

Lines changed: 2 additions & 25 deletions

File tree

runtime/v1/linux/proc/deleted_state.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,3 @@ func (s *deletedState) SetExited(status int) {
6969
func (s *deletedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
7070
return nil, errors.Errorf("cannot exec in a deleted state")
7171
}
72-
73-
func (s *deletedState) Pid() int {
74-
return -1
75-
}

runtime/v1/linux/proc/exec.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ func (e *execProcess) ID() string {
6969
}
7070

7171
func (e *execProcess) Pid() int {
72-
return e.execState.Pid()
73-
}
74-
75-
func (e *execProcess) pidv() int {
72+
e.mu.Lock()
73+
defer e.mu.Unlock()
7674
return e.pid
7775
}
7876

runtime/v1/linux/proc/exec_state.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type execState interface {
3131
Delete(context.Context) error
3232
Kill(context.Context, uint32, bool) error
3333
SetExited(int)
34-
Pid() int
3534
}
3635

3736
type execCreatedState struct {
@@ -83,12 +82,6 @@ func (s *execCreatedState) SetExited(status int) {
8382
}
8483
}
8584

86-
func (s *execCreatedState) Pid() int {
87-
s.p.mu.Lock()
88-
defer s.p.mu.Unlock()
89-
return s.p.pidv()
90-
}
91-
9285
type execRunningState struct {
9386
p *execProcess
9487
}
@@ -127,12 +120,6 @@ func (s *execRunningState) SetExited(status int) {
127120
}
128121
}
129122

130-
func (s *execRunningState) Pid() int {
131-
s.p.mu.Lock()
132-
defer s.p.mu.Unlock()
133-
return s.p.pidv()
134-
}
135-
136123
type execStoppedState struct {
137124
p *execProcess
138125
}
@@ -170,7 +157,3 @@ func (s *execStoppedState) Kill(ctx context.Context, sig uint32, all bool) error
170157
func (s *execStoppedState) SetExited(status int) {
171158
// no op
172159
}
173-
174-
func (s *execStoppedState) Pid() int {
175-
return s.p.pidv()
176-
}

0 commit comments

Comments
 (0)