diff options
Diffstat (limited to 'pkg/instance/instance.go')
| -rw-r--r-- | pkg/instance/instance.go | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index b4460e3ab..df0d74b98 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -40,8 +40,8 @@ type Env interface { type env struct { cfg *mgrconfig.Config optionalFlags bool - buildSem *Semaphore - testSem *Semaphore + buildSem *osutil.Semaphore + testSem *osutil.Semaphore } type BuildKernelConfig struct { @@ -56,7 +56,7 @@ type BuildKernelConfig struct { BuildCPUs int } -func NewEnv(cfg *mgrconfig.Config, buildSem, testSem *Semaphore) (Env, error) { +func NewEnv(cfg *mgrconfig.Config, buildSem, testSem *osutil.Semaphore) (Env, error) { if !vm.AllowsOvercommit(cfg.Type) { return nil, fmt.Errorf("test instances are not supported for %v VMs", cfg.Type) } @@ -508,40 +508,6 @@ func RunnerCmd(prog, fwdAddr, os, arch string, poolIdx, vmIdx int, threaded, new "-threaded=%t -new-env=%t", prog, fwdAddr, os, arch, poolIdx, vmIdx, threaded, newEnv) } -type Semaphore struct { - ch chan struct{} -} - -func NewSemaphore(count int) *Semaphore { - s := &Semaphore{ - ch: make(chan struct{}, count), - } - for i := 0; i < count; i++ { - s.Signal() - } - return s -} - -func (s *Semaphore) Wait() { - <-s.ch -} - -func (s *Semaphore) WaitC() <-chan struct{} { - return s.ch -} - -func (s *Semaphore) Available() int { - return len(s.ch) -} - -func (s *Semaphore) Signal() { - if av := s.Available(); av == cap(s.ch) { - // Not super reliable, but let it be here just in case. - panic(fmt.Sprintf("semaphore capacity (%d) is exceeded (%d)", cap(s.ch), av)) - } - s.ch <- struct{}{} -} - // RunSmokeTest executes syz-manager in the smoke test mode and returns two values: // The crash report, if the testing failed. // An error if there was a problem not related to testing the kernel. |
