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>
This commit is contained in:
parent
716ade8968
commit
9e54c921c8
1 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@ package widgets
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
|
@ -22,6 +23,7 @@ import (
|
||||||
var _ ProvidesMessages = (*AccountView)(nil)
|
var _ ProvidesMessages = (*AccountView)(nil)
|
||||||
|
|
||||||
type AccountView struct {
|
type AccountView struct {
|
||||||
|
sync.Mutex
|
||||||
acct *config.AccountConfig
|
acct *config.AccountConfig
|
||||||
aerc *Aerc
|
aerc *Aerc
|
||||||
conf *config.AercConfig
|
conf *config.AercConfig
|
||||||
|
@ -418,6 +420,8 @@ func (acct *AccountView) GetSortCriteria() []*types.SortCriterion {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (acct *AccountView) CheckMail() {
|
func (acct *AccountView) CheckMail() {
|
||||||
|
acct.Lock()
|
||||||
|
defer acct.Unlock()
|
||||||
if acct.checkingMail {
|
if acct.checkingMail {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -436,7 +440,9 @@ func (acct *AccountView) CheckMail() {
|
||||||
acct.checkingMail = true
|
acct.checkingMail = true
|
||||||
acct.worker.PostAction(msg, func(_ types.WorkerMessage) {
|
acct.worker.PostAction(msg, func(_ types.WorkerMessage) {
|
||||||
acct.SetStatus(statusline.ConnectionActivity(""))
|
acct.SetStatus(statusline.ConnectionActivity(""))
|
||||||
|
acct.Lock()
|
||||||
acct.checkingMail = false
|
acct.checkingMail = false
|
||||||
|
acct.Unlock()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue