fix idle_wait.await result processing

This commit is contained in:
holger krekel
2019-12-15 01:40:39 +01:00
parent b20c33acaa
commit eece5b9ac8

View File

@@ -21,6 +21,9 @@ pub enum Error {
#[fail(display = "IMAP IDLE protocol timed out")] #[fail(display = "IMAP IDLE protocol timed out")]
IdleTimeout(#[cause] async_std::future::TimeoutError), IdleTimeout(#[cause] async_std::future::TimeoutError),
#[fail(display = "IMAP IDLE protocol timed out")]
IdleError(#[cause] async_imap::error::Error),
#[fail(display = "IMAP server does not have IDLE capability")] #[fail(display = "IMAP server does not have IDLE capability")]
IdleAbilityMissing, IdleAbilityMissing,
@@ -80,18 +83,22 @@ impl Imap {
} else { } else {
info!(context, "Idle entering wait-on-remote state"); info!(context, "Idle entering wait-on-remote state");
match idle_wait.await { match idle_wait.await {
IdleResponse::NewData(_) => { Ok(IdleResponse::NewData(_)) => {
info!(context, "Idle has NewData"); info!(context, "Idle has NewData");
} }
// TODO: idle_wait does not distinguish manual interrupts // TODO: idle_wait does not distinguish manual interrupts
// from Timeouts if we would know it's a Timeout we could bail // from Timeouts if we would know it's a Timeout we could bail
// directly and reconnect . // directly and reconnect .
IdleResponse::Timeout => { Ok(IdleResponse::Timeout) => {
info!(context, "Idle-wait timeout or interruption"); info!(context, "Idle-wait timeout or interruption");
} }
IdleResponse::ManualInterrupt => { Ok(IdleResponse::ManualInterrupt) => {
info!(context, "Idle wait was interrupted"); info!(context, "Idle wait was interrupted");
} }
Err(err) => {
self.trigger_reconnect();
return Err(Error::IdleError(err));
}
} }
} }
// if we can't properly terminate the idle // if we can't properly terminate the idle
@@ -134,18 +141,22 @@ impl Imap {
} else { } else {
info!(context, "Idle entering wait-on-remote state"); info!(context, "Idle entering wait-on-remote state");
match idle_wait.await { match idle_wait.await {
IdleResponse::NewData(_) => { Ok(IdleResponse::NewData(_)) => {
info!(context, "Idle has NewData"); info!(context, "Idle has NewData");
} }
// TODO: idle_wait does not distinguish manual interrupts // TODO: idle_wait does not distinguish manual interrupts
// from Timeouts if we would know it's a Timeout we could bail // from Timeouts if we would know it's a Timeout we could bail
// directly and reconnect . // directly and reconnect .
IdleResponse::Timeout => { Ok(IdleResponse::Timeout) => {
info!(context, "Idle-wait timeout or interruption"); info!(context, "Idle-wait timeout or interruption");
} }
IdleResponse::ManualInterrupt => { Ok(IdleResponse::ManualInterrupt) => {
info!(context, "Idle wait was interrupted"); info!(context, "Idle wait was interrupted");
} }
Err(err) => {
self.trigger_reconnect();
return Err(Error::IdleError(err));
}
} }
} }
// if we can't properly terminate the idle // if we can't properly terminate the idle