Commit graph

486 commits

Author SHA1 Message Date
Simon Ser
f1698a337e widgets/msglist: fix MessageList.store race
This field could be written to in the middle of a Draw call, which reads it
multiple times. Use an atomic variable instead.
2019-04-29 09:49:39 -04:00
Simon Ser
089740758c worker/imap: use the IMAP connection from a single goroutine
Unfortunately, the IMAP protocol hasn't been designed to be used from multiple
goroutines at the same time. For instance, if you fetch twice the same message
from two different goroutines, it's not possible to tell whether the response
is for one receiver or the other. For this reason, go-imap clients aren't safe
to use from multiple goroutines.

This commit changes the IMAP workers to be synchronous again (a command is
executed only after the previous one has completed). To use IMAP from different
threads, popular clients (e.g. Thunderbird) typically open multiple
connections.
2019-04-29 09:49:22 -04:00
Simon Ser
072bc26872 Update go-imap to 1.0.0-beta.4
This release contains race conditions fixes.
2019-04-29 09:29:41 -04:00
Simon Ser
335db0402d lib/ui: fix GridCell.invalid race
This is read/written from different goroutines.

    Write at 0x00c00009c6f0 by goroutine 7:
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Grid).cellInvalidated()
          /home/simon/src/aerc2/lib/ui/grid.go:189 +0x122
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Grid).cellInvalidated-fm()
          /home/simon/src/aerc2/lib/ui/grid.go:178 +0x55
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Invalidatable).DoInvalidate()
          /home/simon/src/aerc2/lib/ui/invalidatable.go:22 +0x85
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Bordered).contentInvalidated-fm()
          /home/simon/src/aerc2/lib/ui/borders.go:39 +0x56
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Invalidatable).DoInvalidate()
          /home/simon/src/aerc2/lib/ui/invalidatable.go:22 +0x85
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList.func1()
          /home/simon/src/aerc2/widgets/dirlist.go:81 +0x55
      git.sr.ht/~sircmpwn/aerc2/lib/ui.(*Invalidatable).DoInvalidate()
          /home/simon/src/aerc2/lib/ui/invalidatable.go:22 +0x85
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1()
          /home/simon/src/aerc2/widgets/spinner.go:88 +0x82

    Previous write at 0x00c00009c6f0 by main goroutine:
      [failed to restore the stack]

    Goroutine 7 (running) created at:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start()
          /home/simon/src/aerc2/widgets/spinner.go:46 +0x98
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList()
          /home/simon/src/aerc2/widgets/dirlist.go:37 +0x28b
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView()
          /home/simon/src/aerc2/widgets/account.go:49 +0x5ca
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc()
          /home/simon/src/aerc2/widgets/aerc.go:60 +0x807
      main.main()
          /home/simon/src/aerc2/aerc.go:65 +0x33e
2019-04-29 09:29:37 -04:00
Simon Ser
5685a17674 lib/ui: introduce Invalidatable
Many Drawable implementations have their own Invalidate and OnInvalidate
functions, with an unexported onInvalidate field. However OnInvalidate and
Invalidate are usually not called in the same goroutine. This results in a race
on this field, e.g.:

    Read at 0x00c000094748 by goroutine 7:
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList.func1()
          /home/simon/src/aerc2/widgets/dirlist.go:85 +0x56
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1()
          /home/simon/src/aerc2/widgets/spinner.go:93 +0x1bb

    Previous write at 0x00c000094748 by main goroutine:
      [failed to restore the stack]

    Goroutine 7 (running) created at:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start()
          /home/simon/src/aerc2/widgets/spinner.go:46 +0x8f
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList()
          /home/simon/src/aerc2/widgets/dirlist.go:37 +0x286
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView()
          /home/simon/src/aerc2/widgets/account.go:50 +0x5ca
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc()
          /home/simon/src/aerc2/widgets/aerc.go:60 +0x800
      main.main()
          /home/simon/src/aerc2/aerc.go:65 +0x33e

To fix this, introduce a new type, Invalidatable, which protects the field.
Unfortunately the Drawable must be passed to the callback function in
Invalidate, so we still need to re-implement this in each Invalidatable user.
2019-04-27 14:30:28 -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
Simon Ser
2159eb876e widgets/spinner: fix Spinner.frame race
It's accessed by the goroutine which increments it and the goroutine that draws
the widget at the same time. Use atomic instead.

    Write at 0x00c00000ebc0 by goroutine 7:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1()
          /home/simon/src/aerc2/widgets/spinner.go:50 +0x169

    Previous read at 0x00c00000ebc0 by main goroutine:
      [failed to restore the stack]

    Goroutine 7 (running) created at:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start()
          /home/simon/src/aerc2/widgets/spinner.go:44 +0x8b
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList()
          /home/simon/src/aerc2/widgets/dirlist.go:37 +0x286
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView()
          /home/simon/src/aerc2/widgets/account.go:50 +0x5ca
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc()
          /home/simon/src/aerc2/widgets/aerc.go:60 +0x800
      main.main()
          /home/simon/src/aerc2/aerc.go:65 +0x33e
2019-04-27 11:42:12 -04:00
Elias Naur
e72574c308 go get git.sr.ht/~sircmpwn/go-libvterm
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-21 16:17:40 -04:00
Tom Lebreux
6e11a020d4 Fix segfault on :select-message for unloaded messages
Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-17 20:02:12 -04:00
Drew DeVault
2925bdfd6c Re-render terminal on invalidate 2019-04-15 16:07:05 -04:00
Tom Lebreux
3cd0d5bc28 Fix segfault on :view-message for unloaded message
This also fixes segfault on :view-message on empty directory

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-10 15:40:06 -04:00
Gokberk Yaltirakli
ec09ec8b0e Lowercase MIME types while matching filters 2019-04-07 14:12:19 -04:00
Drew DeVault
4bc8ea34bc Clear damage on each terminal.Draw call 2019-04-05 20:11:31 -04:00
Tom Lebreux
399d014bff Fix wrong row due to typo
Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-05 20:10:28 -04:00
Tom Lebreux
41212a717e Fix infinite loop on empty DirectoryContents
When changing to an empty directory, ml.selected is 0, and the length
of ml.store.Uids is 0. The loop condition is always true so we have
an infinite loop causing 100% CPU usage and prevents us to change to
other directories.

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
2019-04-05 15:24:00 -04:00
Drew DeVault
8a42dfc87c Show (no messages) for empty folders 2019-04-04 14:25:51 -04:00
Drew DeVault
60627c96f5 Use better regex for identifying patches 2019-03-31 16:48:05 -04:00
Drew DeVault
78d3f958e0 Remove show-headers config option
This'll probably look different when we implement it
2019-03-31 16:32:48 -04:00
Drew DeVault
ffd1ffd5ba Remove unused config options
Which are not planned for eventual implementation
2019-03-31 16:29:05 -04:00
Drew DeVault
e5e73d30bf Remove key bindings from aerc.conf
These were moved to binds.conf
2019-03-31 16:09:18 -04:00
Drew DeVault
93695d1e84 Add script for sandboxing w3m 2019-03-31 15:33:07 -04:00
Drew DeVault
315cdf308a Remove extra debug statement 2019-03-31 15:21:33 -04:00
Drew DeVault
36419d85aa Use shell to execute filters, fix non-determinism 2019-03-31 15:21:04 -04:00
Drew DeVault
1a4cc31d67 Make tab width of :pipe consistent 2019-03-31 15:13:47 -04:00
Drew DeVault
958328427a Improve plaintext.py 2019-03-31 14:43:46 -04:00
Drew DeVault
8e5ed2a161 Implement header-regex-match filters 2019-03-31 14:42:18 -04:00
Drew DeVault
f9262e4b06 Improve error handling in message viewer
Still not great but at least it tells you when something went wrong
2019-03-31 14:32:26 -04:00
Drew DeVault
bbdf9df75e Add basic filter implementation 2019-03-31 14:24:53 -04:00
Drew DeVault
711d22891b Decode messages before rendering them 2019-03-31 13:36:37 -04:00
Drew DeVault
56ea7f0e43 Add plaintext highlighter, escape ANSI in source 2019-03-31 12:57:44 -04:00
Drew DeVault
0abafa60e1 Make message viewer real, part two 2019-03-31 12:35:51 -04:00
Drew DeVault
95875b13f8 Rename FetchMessageBodies to FetchFullMessages 2019-03-31 12:19:30 -04:00
Drew DeVault
27b25174e2 Make the message viewer real, part one 2019-03-31 12:14:37 -04:00
Drew DeVault
143289bbd0 Don't parse mail in worker; send a reader instead 2019-03-31 11:29:57 -04:00
Drew DeVault
1f23868652 Pull BodyStructure up from IMAP worker 2019-03-31 11:10:10 -04:00
Drew DeVault
5d0402aeea Add message view commands, :close 2019-03-30 21:45:41 -04:00
Drew DeVault
04d9ab3ce6 Update default config/binds.conf 2019-03-30 21:40:41 -04:00
Drew DeVault
4bdc0f3715 Minor refactoring to header view 2019-03-30 16:50:14 -04:00
Drew DeVault
fd27a2baf6 Fix crash on command not found 2019-03-30 16:29:52 -04:00
Julian P Samaroo
45b4c8a724 Handle no configured accounts gracefully
Instead of throwing a runtime error, when no accounts are configured in
accounts.conf, we provide an informative error message.
2019-03-30 16:26:55 -04:00
Drew DeVault
78db7ccafa Use bold instead of inverted for header names 2019-03-30 15:59:42 -04:00
Drew DeVault
337dd18c9c Add multipart selector mockup to msgviewer 2019-03-30 15:55:21 -04:00
Drew DeVault
ab632d4e97 Actually, git uses cyan for line markers 2019-03-30 15:03:36 -04:00
Drew DeVault
411e247a80 Update hldiff.py to match git more closely 2019-03-30 15:01:24 -04:00
Drew DeVault
fa04a1e036 Add basic message viewer mockup 2019-03-30 14:12:04 -04:00
Drew DeVault
2958579ee7 Correct color of error messages 2019-03-30 13:05:00 -04:00
Drew DeVault
84965d680c Use tcell.Style.Reverse instead of black on white 2019-03-30 12:59:18 -04:00
Drew DeVault
700dea23fa Implement :pipe 2019-03-30 11:58:24 -04:00
Drew DeVault
4465646fed Show deleted emails pending server ack in grey
TODO: Don't let the user select or interact with deleted messages
2019-03-30 10:41:12 -04:00
Drew DeVault
77ede6eb5a Add body fetching support code 2019-03-29 22:36:15 -04:00