aerc/worker
Robin Jarry 420f236d31 imap: fix data race on seqMap array
There are concurrent threads that are accessing and modifying
IMAPWorker.seqMap (the mapping of sequence numbers to message UIDs).
This can lead to crashes when trying to add and remove a message ID.

panic: runtime error: index out of range [391] with length 390

goroutine 1834 [running]:
git.sr.ht/~rjarry/aerc/logging.PanicHandler()
	logging/panic-logger.go:47 +0x6de
panic({0xa41760, 0xc0019b3290})
	/usr/lib/golang/src/runtime/panic.go:838 +0x207
git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleFetchMessages.func1()
	worker/imap/fetch.go:214 +0x185
created by git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleFetchMessages
	worker/imap/fetch.go:209 +0x12b

Use a map which makes more sense than a simple array for random access
operations. Also, it allows better typing for the key values. Protect
the map with a mutex. Add internal API to access the map. Add basic unit
tests to ensure that concurrent access works.

Fixes: https://todo.sr.ht/~rjarry/aerc/49
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-06-24 21:08:12 +02:00
..
handlers go.mod: change base git url 2021-11-05 10:21:45 +01:00
imap imap: fix data race on seqMap array 2022-06-24 21:08:12 +02:00
lib parse: fix content-type parsing error 2022-06-07 16:19:27 +02:00
maildir maildir: fix dirinfo.Unseen and Exists counting 2022-06-14 22:12:37 +02:00
notmuch feat: add background mail polling option for all workers 2022-05-31 14:32:51 +02:00
types imap: add option to cache headers 2022-06-22 11:26:13 +02:00
handler_notmuch.go format: reformat code with go 1.17 2021-12-11 23:24:08 +01:00
worker.go go.mod: change base git url 2021-11-05 10:21:45 +01:00
worker_enabled.go go.mod: change base git url 2021-11-05 10:21:45 +01:00