worker: prevent deadlock by flooding worker.Messages channel
Send to worker.Messages in goroutine to prevent deadlocks: the UI can fill the worker.Actions channel. The worker can generate more than one Message per action, and if it generates enough to fill the worker.Messages channel from a single message while the worker.Actions channel is full, a deadlock occurs. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
f4d6ade429
commit
7473571159
1 changed files with 4 additions and 1 deletions
|
@ -64,7 +64,10 @@ func (worker *Worker) PostMessage(msg WorkerMessage,
|
||||||
} else {
|
} else {
|
||||||
logging.Debugf("PostMessage %T", msg)
|
logging.Debugf("PostMessage %T", msg)
|
||||||
}
|
}
|
||||||
worker.Messages <- msg
|
// This one needs to be in a separate goroutine to prevent deadlocks
|
||||||
|
go func() {
|
||||||
|
worker.Messages <- msg
|
||||||
|
}()
|
||||||
|
|
||||||
if cb != nil {
|
if cb != nil {
|
||||||
worker.messageCallbacks[msg.getId()] = cb
|
worker.messageCallbacks[msg.getId()] = cb
|
||||||
|
|
Loading…
Reference in a new issue