fix(imap): only interrupt existing idle connection

This commit is contained in:
dignifiedquire
2019-05-14 11:24:54 +02:00
parent 4f2bcb5f42
commit 5a1dd3ccbe

View File

@@ -1027,6 +1027,8 @@ impl Imap {
} }
pub fn interrupt_idle(&self) { pub fn interrupt_idle(&self) {
// only kill the connection, if we are actually ideling
if self.session.lock().unwrap().0.is_none() {
if let Some(ref mut stream) = self.session.lock().unwrap().1 { if let Some(ref mut stream) = self.session.lock().unwrap().1 {
match stream.shutdown(net::Shutdown::Both) { match stream.shutdown(net::Shutdown::Both) {
Ok(_) => {} Ok(_) => {}
@@ -1035,7 +1037,9 @@ impl Imap {
} }
} }
} }
}
// interrupt fake idle
let &(ref lock, ref cvar) = &*self.watch.clone(); let &(ref lock, ref cvar) = &*self.watch.clone();
let mut watch = lock.lock().unwrap(); let mut watch = lock.lock().unwrap();