aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-01-02 17:52:58 +0100
committerRobin Jarry <robin@jarry.cc>2023-01-03 16:50:07 +0100
commitddfa5cac1fe9ce602b7b8b5624122cc46f83d62a (patch)
treea37ed198b43ea89bca9c2cfc35423294a1646826 /lib
parentfdb4b272133febba2a5de653eaf256c1f7d61d51 (diff)
downloadaerc-ddfa5cac1fe9ce602b7b8b5624122cc46f83d62a.tar.gz
msgstore: fix deadlock in thread builder
When scrolling while the thread builder is running, aerc freezes. This issue can be easily reproduced by keeping the down arrow pressed while a folder is loading with local threading enabled. This is caused by the threadCallback function calling store.Select which acquires threadsMutex. However, threadCallback is already called with threadsMutex acquired, causing a deadlock. Fix the issue by adding a new selectPriv function that does not acquire the lock and call this one in threadCallback *and* store.Select. Do not reset threadCallback to nil as it was before. Fixes: 6b8e0b19d35a ("split: refactor to prevent stuck splits") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Thomas Vigouroux <me@vigoux.giize.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 1a56b2c8..8b2d0419 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -613,6 +613,10 @@ func (store *MessageStore) Select(uid uint32) {
store.threadCallback = nil
}
store.threadsMutex.Unlock()
+ store.selectPriv(uid)
+}
+
+func (store *MessageStore) selectPriv(uid uint32) {
store.selectedUid = uid
if store.marker != nil {
store.marker.UpdateVisualMark()
@@ -647,7 +651,7 @@ func (store *MessageStore) NextPrev(delta int) {
store.threadsMutex.Lock()
store.threadCallback = func() {
if uids := store.Uids(); len(uids) > newIdx {
- store.Select(uids[newIdx])
+ store.selectPriv(uids[newIdx])
}
}
store.threadsMutex.Unlock()