summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-11-06 09:58:53 +0300
committerValery Piashchynski <[email protected]>2021-11-06 09:58:53 +0300
commitb9d24b98b93b64e359ae7984917a6094c6de991c (patch)
tree784346e6f468b4d6a5caa264c45308023e4d2099
parenta18e8eb737d686a4adf8d965aaf1c5a936c6f8b0 (diff)
update worker's vector
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r--worker_watcher/container/channel/vec.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/worker_watcher/container/channel/vec.go b/worker_watcher/container/channel/vec.go
index fd50c8d1..63df052f 100644
--- a/worker_watcher/container/channel/vec.go
+++ b/worker_watcher/container/channel/vec.go
@@ -69,8 +69,16 @@ func (v *Vec) Push(w worker.BaseProcess) {
// replace with the new one and return from the loop
// new worker can be ttl-ed at this moment, it's possible to replace TTL-ed worker with new TTL-ed worker
// But this case will be handled in the worker_watcher::Get
- v.workers <- w
- return
+ select {
+ case v.workers <- w:
+ return
+ // the place for the new worker was occupied before
+ default:
+ // kill the new worker and reallocate it
+ w.State().Set(worker.StateInvalid)
+ _ = w.Kill()
+ return
+ }
}
}
}