mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 13:36:30 +03:00
Merge pull request #935 from deltachat/address_idle_race
address last(?) idle race condition heuristically
This commit is contained in:
@@ -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)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user