aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 34dd6bc6354cd3592ed51da83de1a0839e08a37d
parent 7c6325977b55385bc65f0a08f4da8ed6dfede52a
Author: Simon Ser <contact@emersion.fr>
Date:   Sun, 19 May 2019 09:50:17 +0000

worker/types/worker: set ID before sending message

The previous code set the message ID after sending it, which could result in
the receiver reading the ID before it's set.

Diffstat:
Mworker/types/worker.go | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/worker/types/worker.go b/worker/types/worker.go @@ -30,11 +30,13 @@ func NewWorker(logger *log.Logger) *Worker { } } -func (worker *Worker) setCallback(msg WorkerMessage, - cb func(msg WorkerMessage)) { - +func (worker *Worker) setId(msg WorkerMessage) { msg.setId(nextId) nextId++ +} + +func (worker *Worker) setCallback(msg WorkerMessage, + cb func(msg WorkerMessage)) { if cb != nil { worker.mutex.Lock() @@ -59,6 +61,8 @@ func (worker *Worker) getCallback(msg WorkerMessage) (func(msg WorkerMessage), func (worker *Worker) PostAction(msg WorkerMessage, cb func(msg WorkerMessage)) { + worker.setId(msg) + if resp := msg.InResponseTo(); resp != nil { worker.Logger.Printf("(ui)=> %T:%T\n", msg, resp) } else { @@ -72,6 +76,8 @@ func (worker *Worker) PostAction(msg WorkerMessage, func (worker *Worker) PostMessage(msg WorkerMessage, cb func(msg WorkerMessage)) { + worker.setId(msg) + if resp := msg.InResponseTo(); resp != nil { worker.Logger.Printf("->(ui) %T:%T\n", msg, resp) } else {