diff options
author | Valery Piashchynski <[email protected]> | 2020-08-27 23:37:21 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-08-27 23:37:21 +0300 |
commit | a636683ca900a7413c439fb81bae7361191f016d (patch) | |
tree | 1959823341a7c7d91a657d38bfbfeeea8dcebbe1 | |
parent | 9103939fa98de53170d2bf0e8cd74529786d7ab2 (diff) |
attempt to fix npe in mutex.
Since we are using pointer receiver for the StaticPool struct, there is
no sense to use pointers to define a mutexes
-rw-r--r-- | static_pool.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/static_pool.go b/static_pool.go index ac9c2529..c7cc6517 100644 --- a/static_pool.go +++ b/static_pool.go @@ -2,11 +2,12 @@ package roadrunner import ( "fmt" - "github.com/pkg/errors" "os/exec" "sync" "sync/atomic" "time" + + "github.com/pkg/errors" ) const ( @@ -26,7 +27,7 @@ type StaticPool struct { factory Factory // active task executions - tmu *sync.Mutex + tmu sync.Mutex tasks sync.WaitGroup // workers circular allocation buf @@ -36,13 +37,13 @@ type StaticPool struct { numDead int64 // protects state of worker list, does not affect allocation - muw *sync.RWMutex + muw sync.RWMutex // all registered workers workers []*Worker // invalid declares set of workers to be removed from the pool. - remove *sync.Map + remove sync.Map // pool is being destroyed inDestroy int32 @@ -66,9 +67,6 @@ func NewPool(cmd func() *exec.Cmd, factory Factory, cfg Config) (*StaticPool, er workers: make([]*Worker, 0, cfg.NumWorkers), free: make(chan *Worker, cfg.NumWorkers), destroy: make(chan interface{}), - tmu: &sync.Mutex{}, - remove: &sync.Map{}, - muw: &sync.RWMutex{}, } // constant number of workers simplify logic |