diff options
-rw-r--r-- | server.go | 2 | ||||
-rw-r--r-- | static_pool.go | 4 | ||||
-rw-r--r-- | static_pool_test.go | 5 |
3 files changed, 7 insertions, 4 deletions
@@ -123,13 +123,13 @@ func (srv *Server) Reconfigure(cfg *ServerConfig) error { srv.mu.Unlock() pool, err := NewPool(cfg.makeCommand(), srv.factory, *cfg.Pool) + srv.pool.Listen(srv.poolListener) if err != nil { return err } srv.mu.Lock() srv.cfg.Pool, srv.pool = cfg.Pool, pool - srv.pool.Listen(srv.poolListener) srv.mu.Unlock() srv.throw(EventPoolConstruct, pool) diff --git a/static_pool.go b/static_pool.go index 18bfaf60..24665c01 100644 --- a/static_pool.go +++ b/static_pool.go @@ -169,13 +169,15 @@ func (p *StaticPool) allocateWorker() (w *Worker, err error) { return nil, fmt.Errorf("worker timeout (%s)", p.cfg.AllocateTimeout) case w = <-p.free: timeout.Stop() + if w.State().Value() != StateReady { continue } + return w, nil } } - return w, nil + return nil, fmt.Errorf("all workers are dead (%v)", p.cfg.NumWorkers) } // release releases or replaces the worker. diff --git a/static_pool_test.go b/static_pool_test.go index 548fb126..231bc71b 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -2,13 +2,13 @@ package roadrunner import ( "github.com/stretchr/testify/assert" - "log" "os/exec" "runtime" "strconv" - "sync" "testing" "time" + "sync" + "log" ) var cfg = Config{ @@ -266,6 +266,7 @@ func Test_StaticPool_Replace_Worker(t *testing.T) { } } + // identical to replace but controlled on worker side func Test_StaticPool_Stop_Worker(t *testing.T) { p, err := NewPool( |