Timeout for sending IMAP update

This commit is contained in:
Michal Horejsek
2020-09-03 08:47:35 +02:00
parent 6671b78799
commit 7430c7f1f5

View File

@ -123,8 +123,16 @@ func (store *Store) imapSendUpdate(update imapBackend.Update) {
}
done := update.Done()
go func() { store.imapUpdates <- update }()
go func() {
// This timeout is to not keep running many blocked goroutines.
// In case nothing listens to this channel, this thread should stop.
select {
case store.imapUpdates <- update:
case <-time.After(1 * time.Second):
}
}()
// This timeout is to not block IMAP backend by wait for IMAP client.
select {
case <-done:
case <-time.After(1 * time.Second):