diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-28 15:21:21 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-28 15:21:21 +0000 |
commit | 960c0a4f8569e10ad318fd2e9d266345ddff4fa3 (patch) | |
tree | cc6d00cf347234a85f10dd4d72b2cba1775767d5 | |
parent | fea88ad23d8686ec6ddbeb48f5cfc7b2640c036e (diff) | |
parent | a636683ca900a7413c439fb81bae7361191f016d (diff) |
Merge #356
356: Attempt to fix npe in the StaticPool mutex r=48d90782 a=48d90782
Since we are using pointer receiver for the StaticPool struct, there is no sense to use pointers to define mutexes.
Co-authored-by: Valery Piashchynski <[email protected]>
-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 |