mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
[wip] initial detection of idle done() not working
This commit is contained in:
@@ -18,6 +18,9 @@ pub enum Error {
|
|||||||
#[fail(display = "IMAP IDLE protocol failed to init/complete")]
|
#[fail(display = "IMAP IDLE protocol failed to init/complete")]
|
||||||
IdleProtocolFailed(#[cause] async_imap::error::Error),
|
IdleProtocolFailed(#[cause] async_imap::error::Error),
|
||||||
|
|
||||||
|
#[fail(display = "IMAP IDLE protocol timed out")]
|
||||||
|
IdleTimeout(String),
|
||||||
|
|
||||||
#[fail(display = "IMAP server does not have IDLE capability")]
|
#[fail(display = "IMAP server does not have IDLE capability")]
|
||||||
IdleAbilityMissing,
|
IdleAbilityMissing,
|
||||||
|
|
||||||
@@ -91,17 +94,26 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match handle.done().await {
|
// if we can't properly terminate the idle
|
||||||
Ok(session) => {
|
// protocol let's break the connection.
|
||||||
|
let res = async_std::future::timeout(Duration::from_secs(15), async {
|
||||||
|
handle.done().await
|
||||||
|
});
|
||||||
|
match res.await {
|
||||||
|
Ok(Ok(session)) => {
|
||||||
*self.session.lock().await = Some(Session::Secure(session));
|
*self.session.lock().await = Some(Session::Secure(session));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Ok(Err(err)) => {
|
||||||
// if we cannot terminate IDLE it probably
|
// if we cannot terminate IDLE it probably
|
||||||
// means that we waited long (with idle_wait)
|
// means that we waited long (with idle_wait)
|
||||||
// but the network went away/changed
|
// but the network went away/changed
|
||||||
self.trigger_reconnect();
|
self.trigger_reconnect();
|
||||||
return Err(Error::IdleProtocolFailed(err));
|
return Err(Error::IdleProtocolFailed(err));
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
self.trigger_reconnect();
|
||||||
|
return Err(Error::IdleTimeout(err.to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IdleHandle::Insecure(mut handle) => {
|
IdleHandle::Insecure(mut handle) => {
|
||||||
@@ -135,17 +147,26 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match handle.done().await {
|
// if we can't properly terminate the idle
|
||||||
Ok(session) => {
|
// protocol let's break the connection.
|
||||||
|
let res = async_std::future::timeout(Duration::from_secs(15), async {
|
||||||
|
handle.done().await
|
||||||
|
});
|
||||||
|
match res.await {
|
||||||
|
Ok(Ok(session)) => {
|
||||||
*self.session.lock().await = Some(Session::Insecure(session));
|
*self.session.lock().await = Some(Session::Insecure(session));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Ok(Err(err)) => {
|
||||||
// if we cannot terminate IDLE it probably
|
// if we cannot terminate IDLE it probably
|
||||||
// means that we waited long (with idle_wait)
|
// means that we waited long (with idle_wait)
|
||||||
// but the network went away/changed
|
// but the network went away/changed
|
||||||
self.trigger_reconnect();
|
self.trigger_reconnect();
|
||||||
return Err(Error::IdleProtocolFailed(err));
|
return Err(Error::IdleProtocolFailed(err));
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
self.trigger_reconnect();
|
||||||
|
return Err(Error::IdleTimeout(err.to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user