From 25827915017e3558cfae3c2cfc1389c0dfda054f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 1 Dec 2019 11:58:33 +0100 Subject: [PATCH 1/2] address #925 heuristically --- src/imap.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/imap.rs b/src/imap.rs index d01517bd8..a4409a15d 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -984,6 +984,11 @@ impl Imap { } // let's manually drop the StopSource if interrupt.is_some() { + // 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(50)); eprintln!("low-level: dropping stop-source to interrupt idle"); std::mem::drop(interrupt) } From 2423d197cd949374be8b799d51a64f23d57ec7a8 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 1 Dec 2019 12:30:43 +0100 Subject: [PATCH 2/2] better logging, changed timeout --- src/imap.rs | 6 +++--- src/job_thread.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/imap.rs b/src/imap.rs index a4409a15d..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() { @@ -988,8 +988,8 @@ impl Imap { // 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(50)); - eprintln!("low-level: dropping stop-source to interrupt idle"); + 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();