diff options
author | Wolfy-J <[email protected]> | 2018-09-23 15:47:55 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-23 15:47:55 +0300 |
commit | 0d826d29d27cdc83766ceb60c33444603f67ade1 (patch) | |
tree | 0bb3af3528481af163d331104bd672bfc2794117 | |
parent | d208fa427bedeed367be4bab6d5285eb0a8984fb (diff) |
task wait group protection added
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rwxr-xr-x | build.sh | 2 | ||||
-rw-r--r-- | static_pool.go | 7 | ||||
-rw-r--r-- | static_pool_test.go | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bd5cde..52eccc47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +v1.2.2 (23.09.2018) +- new project directory structure +- introduces DefaultsConfig, allows to keep config files smaller +- better worker pool destruction while working with long running processes +- added more php versions to travis config +- `Spiral\RoadRunner\Exceptions\RoadRunnerException` is marked as deprecated in favor of `Spiral\RoadRunner\Exception\RoadRunnerException` +- improved test coverage + v1.2.1 (21.09.2018) ------ - added RR_HTTP env variable to php processes run under http service @@ -2,7 +2,7 @@ cd $(dirname "${BASH_SOURCE[0]}") OD="$(pwd)" # Pushes application version into the build information. -RR_VERSION=1.2.1 +RR_VERSION=1.2.2 # Hardcode some values to the core package LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}" diff --git a/static_pool.go b/static_pool.go index b6e43ddc..432c9adc 100644 --- a/static_pool.go +++ b/static_pool.go @@ -26,6 +26,7 @@ type StaticPool struct { factory Factory // active task executions + tmu sync.Mutex tasks sync.WaitGroup // workers circular allocation buf @@ -112,7 +113,10 @@ func (p *StaticPool) Workers() (workers []*Worker) { // Exec one task with given payload and context, returns result or error. func (p *StaticPool) Exec(rqs *Payload) (rsp *Payload, err error) { + p.tmu.Lock() p.tasks.Add(1) + p.tmu.Unlock() + defer p.tasks.Done() w, err := p.allocateWorker() @@ -147,7 +151,10 @@ func (p *StaticPool) Exec(rqs *Payload) (rsp *Payload, err error) { func (p *StaticPool) Destroy() { atomic.AddInt32(&p.inDestroy, 1) close(p.destroy) + + p.tmu.Lock() p.tasks.Wait() + p.tmu.Unlock() var wg sync.WaitGroup for _, w := range p.Workers() { diff --git a/static_pool_test.go b/static_pool_test.go index 0259bc33..1e4906a5 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -371,7 +371,7 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) { } // identical to replace but controlled on worker side -func Test_Static_Pool_Slow_Destory(t *testing.T) { +func Test_Static_Pool_Slow_Destroy(t *testing.T) { p, err := NewPool( func() *exec.Cmd { return exec.Command("php", "tests/slow-destroy.php", "echo", "pipes") }, NewPipeFactory(), |