diff options
author | Valery Piashchynski <[email protected]> | 2021-12-14 12:11:19 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-12-14 14:15:45 +0300 |
commit | 253d7f7abf7a53b5249c08949372da5c9b687b04 (patch) | |
tree | a4ad76ae4fb8a953f7f2e465a99728775eb9179f /pool | |
parent | 8c3420cb0d05036bc69f8dcc14ef832860a3c3d4 (diff) |
protect pool operations and sync with workers checks
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pool')
-rwxr-xr-x | pool/supervisor_pool.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pool/supervisor_pool.go b/pool/supervisor_pool.go index a7a1ae52..b01520e2 100755 --- a/pool/supervisor_pool.go +++ b/pool/supervisor_pool.go @@ -54,12 +54,16 @@ func (sp *supervised) execWithTTL(_ context.Context, _ *payload.Payload) (*paylo func (sp *supervised) Exec(rqs *payload.Payload) (*payload.Payload, error) { const op = errors.Op("supervised_exec_with_context") if sp.cfg.ExecTTL == 0 { + sp.mu.RLock() + defer sp.mu.RUnlock() return sp.pool.Exec(rqs) } ctx, cancel := context.WithTimeout(context.Background(), sp.cfg.ExecTTL) defer cancel() + sp.mu.RLock() + defer sp.mu.RUnlock() res, err := sp.pool.execWithTTL(ctx, rqs) if err != nil { return nil, errors.E(op, err) |