diff options
author | Valery Piashchynski <[email protected]> | 2021-05-13 17:15:00 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-13 17:15:00 +0300 |
commit | 2be94ad0400e2f523d87f47e09a7bf505edef689 (patch) | |
tree | 1824c8ee28d0c6ce2884b99d0a4eaa99dcaa9cbb /pkg/pool/static_pool.go | |
parent | 705b69631dc91323c64a19594dcfeca06ea4fa5a (diff) |
- Remove unsafe casting (replace with a less unsafe)
- Make the static plugin great again (separate plugin)
- Revert new behavior
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/pool/static_pool.go')
-rwxr-xr-x | pkg/pool/static_pool.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index 6ef2373a..d57cc95c 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -4,7 +4,6 @@ import ( "context" "os/exec" "time" - "unsafe" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/pkg/events" @@ -12,6 +11,7 @@ import ( "github.com/spiral/roadrunner/v2/pkg/transport" "github.com/spiral/roadrunner/v2/pkg/worker" workerWatcher "github.com/spiral/roadrunner/v2/pkg/worker_watcher" + "github.com/spiral/roadrunner/v2/utils" ) // StopRequest can be sent by worker to indicate that restart is required. @@ -153,7 +153,7 @@ func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) { } // worker want's to be terminated - if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest { + if len(rsp.Body) == 0 && utils.AsString(rsp.Context) == StopRequest { sp.stopWorker(w) return sp.Exec(p) } @@ -187,7 +187,7 @@ func (sp *StaticPool) execWithTTL(ctx context.Context, p payload.Payload) (paylo } // worker want's to be terminated - if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest { + if len(rsp.Body) == 0 && utils.AsString(rsp.Context) == StopRequest { sp.stopWorker(w) return sp.execWithTTL(ctx, p) } @@ -347,8 +347,3 @@ func (sp *StaticPool) allocateWorkers(numWorkers uint64) ([]worker.BaseProcess, } return workers, nil } - -// unsafe, but lightning fast []byte to string conversion -func toString(data []byte) string { - return *(*string)(unsafe.Pointer(&data)) -} |