summaryrefslogtreecommitdiffstats
path: root/src/conf
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-09-14 19:32:43 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-09-14 19:32:43 +0300
commit17a4ccdcbc37977cf7c4c17b8180a922936ee2f5 (patch)
tree2d0549fb266783b652665937475e0f7faaf15756 /src/conf
parent670675edcc48480a8e250d9b2b06b69c837df51c (diff)
melib/imap: perform reconnect on IDLE failure
Diffstat (limited to 'src/conf')
-rw-r--r--src/conf/accounts.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs
index 469b3c59..040f53dc 100644
--- a/src/conf/accounts.rs
+++ b/src/conf/accounts.rs
@@ -1355,24 +1355,19 @@ impl Account {
let mut timeout = false;
let mut drain: SmallVec<[std::time::Instant; 16]> = SmallVec::new();
const ONLINE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
- for (_instant, j) in self
+ for (_instant, _) in self
.active_job_instants
.range(..std::time::Instant::now() - ONLINE_TIMEOUT)
{
- if self.active_jobs.contains_key(j) {
- debug!("timeout for {} {:?}", j, self.active_jobs[j]);
- let req = self.active_jobs.remove(j).unwrap();
- self.sender
- .send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
- StatusEvent::JobCanceled(*j),
- )))
- .unwrap();
- timeout |= !req.is_watch();
- }
drain.push(*_instant);
}
- for j in drain {
- self.active_job_instants.remove(&j);
+ for inst in drain {
+ if let Some(j) = self.active_job_instants.remove(&inst) {
+ if let Some(req) = self.cancel_job(j) {
+ debug!("timeout for {} {:?}", j, &req);
+ timeout |= !req.is_watch();
+ }
+ }
}
if self.is_online.is_err()
&& self
@@ -2009,6 +2004,19 @@ impl Account {
)))
.unwrap();
}
+
+ pub fn cancel_job(&mut self, job_id: JobId) -> Option<JobRequest> {
+ if let Some(req) = self.active_jobs.remove(&job_id) {
+ self.sender
+ .send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
+ StatusEvent::JobCanceled(job_id),
+ )))
+ .unwrap();
+ Some(req)
+ } else {
+ None
+ }
+ }
}
impl Index<&MailboxHash> for Account {