add dc_accounts_maybe_network_lost() (#2550)

This commit is contained in:
bjoern
2021-07-22 11:29:51 +02:00
committed by GitHub
parent 5f365b259b
commit 980d2a9433
4 changed files with 53 additions and 1 deletions

View File

@@ -44,6 +44,13 @@ impl Context {
connectivity::idle_interrupted(lock).await;
}
/// Indicate that the network likely is lost.
pub async fn maybe_network_lost(&self) {
let lock = self.scheduler.read().await;
lock.maybe_network_lost().await;
connectivity::idle_interrupted(lock).await;
}
pub(crate) async fn interrupt_inbox(&self, info: InterruptInfo) {
self.scheduler.read().await.interrupt_inbox(info).await;
}
@@ -425,6 +432,18 @@ impl Scheduler {
.await;
}
async fn maybe_network_lost(&self) {
if !self.is_running() {
return;
}
self.interrupt_inbox(InterruptInfo::new(false, None))
.join(self.interrupt_mvbox(InterruptInfo::new(false, None)))
.join(self.interrupt_sentbox(InterruptInfo::new(false, None)))
.join(self.interrupt_smtp(InterruptInfo::new(false, None)))
.await;
}
async fn interrupt_inbox(&self, info: InterruptInfo) {
if let Scheduler::Running { ref inbox, .. } = self {
inbox.interrupt(info).await;