safer interruptability of fake-idle -- reusing the same skip_next_idle pattern as with idle

This commit is contained in:
holger krekel
2019-11-25 23:45:57 +01:00
parent 59700cb477
commit 618d74cd67
3 changed files with 37 additions and 29 deletions

View File

@@ -886,7 +886,12 @@ impl Imap {
let interval = async_std::stream::interval(Duration::from_secs(60)); let interval = async_std::stream::interval(Duration::from_secs(60));
let mut interrupt_interval = interrupt.stop_token().stop_stream(interval); let mut interrupt_interval = interrupt.stop_token().stop_stream(interval);
*self.interrupt.lock().await = Some(interrupt); *self.interrupt.lock().await = Some(interrupt);
if self.skip_next_idle_wait.load(Ordering::SeqCst) {
// interrupt_idle has happened before we
// provided self.interrupt
self.skip_next_idle_wait.store(false, Ordering::SeqCst);
info!(context, "fake-idle wait was skipped");
} else {
// loop until we are interrupted or if we fetched something // loop until we are interrupted or if we fetched something
while let Some(_) = interrupt_interval.next().await { while let Some(_) = interrupt_interval.next().await {
// try to connect with proper login params // try to connect with proper login params
@@ -921,6 +926,7 @@ impl Imap {
} }
} }
} }
}
self.interrupt.lock().await.take(); self.interrupt.lock().await.take();
info!( info!(

View File

@@ -1011,4 +1011,5 @@ pub fn interrupt_smtp_idle(context: &Context) {
state.perform_jobs_needed = 1; state.perform_jobs_needed = 1;
state.idle = true; state.idle = true;
cvar.notify_one(); cvar.notify_one();
info!(context, "Interrupting SMTP-idle... ended",);
} }

View File

@@ -70,6 +70,7 @@ impl JobThread {
state.idle = true; state.idle = true;
cvar.notify_one(); cvar.notify_one();
info!(context, "Interrupting {}-IDLE... finished", self.name);
} }
pub fn fetch(&mut self, context: &Context, use_network: bool) { pub fn fetch(&mut self, context: &Context, use_network: bool) {