Skip to content

Commit 75a3815

Browse files
authored
Simplfy subprocess Stop & remove useless test (ava-labs#2652)
1 parent 9f42ae0 commit 75a3815

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

utils/ulimit/ulimit_test.go

Lines changed: 0 additions & 18 deletions
This file was deleted.

vms/rpcchainvm/runtime/subprocess/stopper.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,13 @@ func NewStopper(logger logging.Logger, cmd *exec.Cmd) runtime.Stopper {
2020
}
2121

2222
type stopper struct {
23-
lock sync.Mutex
24-
cmd *exec.Cmd
25-
shutdown bool
26-
23+
once sync.Once
24+
cmd *exec.Cmd
2725
logger logging.Logger
2826
}
2927

3028
func (s *stopper) Stop(ctx context.Context) {
31-
s.lock.Lock()
32-
defer s.lock.Unlock()
33-
34-
// subsequent calls to this method are a no-op
35-
if s.shutdown || s.cmd.Process == nil {
36-
return
37-
}
38-
39-
s.shutdown = true
40-
stop(ctx, s.logger, s.cmd)
29+
s.once.Do(func() {
30+
stop(ctx, s.logger, s.cmd)
31+
})
4132
}

0 commit comments

Comments
 (0)