diff --git a/src/imap.rs b/src/imap.rs index d01517bd8..bbcd006a6 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -972,7 +972,7 @@ impl Imap { }) } - pub fn interrupt_idle(&self) { + pub fn interrupt_idle(&self, context: &Context) { task::block_on(async move { let mut interrupt: Option = self.interrupt.lock().await.take(); if interrupt.is_none() { @@ -984,7 +984,12 @@ impl Imap { } // let's manually drop the StopSource if interrupt.is_some() { - eprintln!("low-level: dropping stop-source to interrupt idle"); + // the imap thread provided us a stop token but might + // not have entered idle_wait yet, give it some time + // for that to happen. XXX handle this without extra wait + // https://github.com/deltachat/deltachat-core-rust/issues/925 + std::thread::sleep(Duration::from_millis(200)); + info!(context, "low-level: dropping stop-source to interrupt idle"); std::mem::drop(interrupt) } }); diff --git a/src/job_thread.rs b/src/job_thread.rs index 106f98520..4c7e57f11 100644 --- a/src/job_thread.rs +++ b/src/job_thread.rs @@ -63,7 +63,7 @@ impl JobThread { info!(context, "Interrupting {}-IDLE...", self.name); - self.imap.interrupt_idle(); + self.imap.interrupt_idle(context); let &(ref lock, ref cvar) = &*self.state.clone(); let mut state = lock.lock().unwrap();