Skip to content

Commit

Permalink
Simplfy subprocess Stop & remove useless test (ava-labs#2652)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexfusion authored Feb 24, 2023
1 parent 9f42ae0 commit 75a3815
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
18 changes: 0 additions & 18 deletions utils/ulimit/ulimit_test.go

This file was deleted.

19 changes: 5 additions & 14 deletions vms/rpcchainvm/runtime/subprocess/stopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@ func NewStopper(logger logging.Logger, cmd *exec.Cmd) runtime.Stopper {
}

type stopper struct {
lock sync.Mutex
cmd *exec.Cmd
shutdown bool

once sync.Once
cmd *exec.Cmd
logger logging.Logger
}

func (s *stopper) Stop(ctx context.Context) {
s.lock.Lock()
defer s.lock.Unlock()

// subsequent calls to this method are a no-op
if s.shutdown || s.cmd.Process == nil {
return
}

s.shutdown = true
stop(ctx, s.logger, s.cmd)
s.once.Do(func() {
stop(ctx, s.logger, s.cmd)
})
}

0 comments on commit 75a3815

Please sign in to comment.