diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-09-25 14:38:46 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-09-26 17:32:00 +0200 |
commit | 9e54c921c83fedb3b816e1a98b30e1ff2a10b542 (patch) | |
tree | c49bbfd111672e32cfbffa19972ef16aaa9d02e7 /widgets/account.go | |
parent | 716ade89687150daadbb41bdec4a00d6d6e34193 (diff) | |
download | aerc-9e54c921c83fedb3b816e1a98b30e1ff2a10b542.tar.gz |
checkmail: protect access to acct.checkingmail
A data race exists between the timer goroutine and the main goroutine
for checking / setting the status of acct.checkingmail. Protect access
to this value with a mutex
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/widgets/account.go b/widgets/account.go index 8cac373b..382a07a8 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -3,6 +3,7 @@ package widgets import ( "errors" "fmt" + "sync" "time" "github.com/gdamore/tcell/v2" @@ -22,6 +23,7 @@ import ( var _ ProvidesMessages = (*AccountView)(nil) type AccountView struct { + sync.Mutex acct *config.AccountConfig aerc *Aerc conf *config.AercConfig @@ -418,6 +420,8 @@ func (acct *AccountView) GetSortCriteria() []*types.SortCriterion { } func (acct *AccountView) CheckMail() { + acct.Lock() + defer acct.Unlock() if acct.checkingMail { return } @@ -436,7 +440,9 @@ func (acct *AccountView) CheckMail() { acct.checkingMail = true acct.worker.PostAction(msg, func(_ types.WorkerMessage) { acct.SetStatus(statusline.ConnectionActivity("")) + acct.Lock() acct.checkingMail = false + acct.Unlock() }) } |