diff options
author | Valery Piashchynski <[email protected]> | 2020-12-17 10:11:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-17 10:11:23 +0300 |
commit | 8422e300f64f20d86ffccf773d41109285bbc12d (patch) | |
tree | 2c66ade061a7c2af1239515b431e50c7627b0ba5 /pkg | |
parent | 26c6e2c481921760f0f2cc98fdbb022ed1c54a48 (diff) |
Attempt to fix race #1
Diffstat (limited to 'pkg')
-rwxr-xr-x | pkg/worker_watcher/worker_watcher.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/worker_watcher/worker_watcher.go b/pkg/worker_watcher/worker_watcher.go index 8788e509..170a6ac8 100755 --- a/pkg/worker_watcher/worker_watcher.go +++ b/pkg/worker_watcher/worker_watcher.go @@ -279,11 +279,13 @@ func (ww *workerWatcher) wait(w worker.BaseProcess) { const op = errors.Op("process wait") err := w.Wait() if err != nil { + ww.mutex.Lock() ww.events.Push(events.WorkerEvent{ Event: events.EventWorkerError, Worker: w, Payload: errors.E(op, err), }) + ww.mutex.Unlock() } if w.State().Value() == internal.StateDestroyed { @@ -294,10 +296,12 @@ func (ww *workerWatcher) wait(w worker.BaseProcess) { _ = ww.stack.FindAndRemoveByPid(w.Pid()) err = ww.AllocateNew() if err != nil { + ww.mutex.Lock() ww.events.Push(events.PoolEvent{ Event: events.EventPoolError, Payload: errors.E(op, err), }) + ww.mutex.Unlock() } } |