Commit Graph

11 Commits

Author SHA1 Message Date
Tim Culverhouse f4d6ade429 imap: prevent deadlock from posting actions to self
The IMAP worker has a few methods that post a new Action to itself. This
can create a deadlock when the worker.Actions channel is full: The
worker can't accept a new Action because it's trying to post an action.
This is most noticeable when cached headers are enabled and the message
list is scrolled fast.

Use a goroutine to post actions to the worker when posting from within
the worker.

Fixes: https://todo.sr.ht/~rjarry/aerc/45
Fixes: 7aa71d334b ("imap: add option to cache headers")
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-20 00:03:36 +02:00
Moritz Poldrack aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Robin Jarry cd19995557 logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make
them consistent with the new logging API. Avoid using %v when a more
specific verb exists for the argument types.

The loggers are completely disabled (i.e. Sprintf is not even called)
by default. They are only enabled when redirecting stdout to a file.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-23 22:52:15 +02:00
Drew DeVault a81467dda9 Remove worker callbacks when Done is received 2019-06-02 13:20:02 -04:00
Simon Ser 248345d875 worker/types/worker: remove mutex
Worker.callbacks contains two types of callbacks: some are action callbacks,
some are message callbacks. Each of those is access from one side of the
communication channel (UI goroutine vs. worker goroutine).

Instead of using a channel, we can use two different maps for each kind. This
simplifies the code and also ensures we don't call an action callback instead
of a message callback (or the other way around).
2019-05-19 11:51:25 -04:00
Simon Ser f27db33305 worker/types/worker: make ID allocation atomic
Message IDs are allocated for both messages from UI to workers and the other
way around. Hence, the global nextId variable is accessed from multiple
goroutines.

Instead, use atomic to access the global counter.
2019-05-19 11:51:22 -04:00
Simon Ser 34dd6bc635 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.
2019-05-19 11:51:20 -04:00
Drew DeVault b0bf09b98f Copy sent emails to the Sent folder
Or rather, to a user-specified folder
2019-05-15 19:41:21 -04:00
Simon Ser 9ef2a57b51 worker/types: fix Worker.Callbacks race condition
Worker.Process* functions were called in different goroutines than
Worker.Post*. Protect the map with a mutex. Also make the map unexported to
prevent external unprotected accesses.

Worker.Process* functions used to delete items from the map. However they
didn't delete the element they retrieved: callbacks[msg.InResponseTo()] was
read while callbacks[msg] was deleted. I'm not sure I understand why. I tried
to delete the element that was accessed - but this broke everything (UI froze
at "Connecting..."). I don't believe any elements were actually removed from
the map, so the new code just doesn't remove anything.
2019-04-27 14:28:26 -04:00
Drew DeVault 1767e4fab5 Improve logging 2018-02-01 18:59:13 -05:00
Drew DeVault d24e4712a4 Reduce boilerplate in worker/UI 2018-02-01 18:42:03 -05:00