summaryrefslogtreecommitdiff
path: root/pool
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-12-14 12:11:19 +0300
committerValery Piashchynski <[email protected]>2021-12-14 12:11:19 +0300
commit50944620fabb8cfa1d2bbbc50f64db457c4837ad (patch)
treea4ad76ae4fb8a953f7f2e465a99728775eb9179f /pool
parentc588b446a45214577c76b185f4363853aa6ccb7c (diff)
protect pool operations and sync with workers checks
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pool')
-rwxr-xr-xpool/supervisor_pool.go4
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)