mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +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")]
|
||||
IdleProtocolFailed(#[cause] async_imap::error::Error),
|
||||
|
||||
#[fail(display = "IMAP IDLE protocol timed out")]
|
||||
IdleTimeout(String),
|
||||
|
||||
#[fail(display = "IMAP server does not have IDLE capability")]
|
||||
IdleAbilityMissing,
|
||||
|
||||
@@ -91,17 +94,26 @@ impl Imap {
|
||||
}
|
||||
}
|
||||
}
|
||||
match handle.done().await {
|
||||
Ok(session) => {
|
||||
// if we can't properly terminate the idle
|
||||
// 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));
|
||||
}
|
||||
Err(err) => {
|
||||
Ok(Err(err)) => {
|
||||
// if we cannot terminate IDLE it probably
|
||||
// means that we waited long (with idle_wait)
|
||||
// but the network went away/changed
|
||||
self.trigger_reconnect();
|
||||
return Err(Error::IdleProtocolFailed(err));
|
||||
}
|
||||
Err(err) => {
|
||||
self.trigger_reconnect();
|
||||
return Err(Error::IdleTimeout(err.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
IdleHandle::Insecure(mut handle) => {
|
||||
@@ -135,17 +147,26 @@ impl Imap {
|
||||
}
|
||||
}
|
||||
}
|
||||
match handle.done().await {
|
||||
Ok(session) => {
|
||||
// if we can't properly terminate the idle
|
||||
// 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));
|
||||
}
|
||||
Err(err) => {
|
||||
Ok(Err(err)) => {
|
||||
// if we cannot terminate IDLE it probably
|
||||
// means that we waited long (with idle_wait)
|
||||
// but the network went away/changed
|
||||
self.trigger_reconnect();
|
||||
return Err(Error::IdleProtocolFailed(err));
|
||||
}
|
||||
Err(err) => {
|
||||
self.trigger_reconnect();
|
||||
return Err(Error::IdleTimeout(err.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user