Merge pull request #935 from deltachat/address_idle_race

address last(?) idle race condition heuristically
This commit is contained in:
björn petersen
2019-12-01 19:26:40 +01:00
committed by GitHub
2 changed files with 8 additions and 3 deletions

View File

@@ -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<stop_token::StopSource> = 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)
}
});

View File

@@ -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();