Handle Dovecot's periodic IDLE notification messages ("OK Still here").
These messages show up at an interval controlled by Dovecot's imap_idle_notify_interval setting, which defaults to 2 minutes. These messages were causing the IDLE loop to exit prematurely because it looks like a notification response from the server.
This commit is contained in:
parent
1b7ba0b0b1
commit
746bdfe6b9
1 changed files with 19 additions and 9 deletions
|
|
@ -93,16 +93,26 @@ impl<'a, T: Read + Write + 'a> Handle<'a, T> {
|
||||||
/// This is necessary so that we can keep using the inner `Session` in `wait_keepalive`.
|
/// This is necessary so that we can keep using the inner `Session` in `wait_keepalive`.
|
||||||
fn wait_inner(&mut self) -> Result<()> {
|
fn wait_inner(&mut self) -> Result<()> {
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
|
loop {
|
||||||
match self.session.readline(&mut v).map(|_| ()) {
|
match self.session.readline(&mut v).map(|_| ()) {
|
||||||
Err(Error::Io(ref e))
|
Err(Error::Io(ref e))
|
||||||
if e.kind() == io::ErrorKind::TimedOut || e.kind() == io::ErrorKind::WouldBlock =>
|
if e.kind() == io::ErrorKind::TimedOut
|
||||||
|
|| e.kind() == io::ErrorKind::WouldBlock =>
|
||||||
{
|
{
|
||||||
// we need to refresh the IDLE connection
|
// we need to refresh the IDLE connection
|
||||||
self.terminate()?;
|
self.terminate()?;
|
||||||
self.init()?;
|
self.init()?;
|
||||||
self.wait_inner()
|
return self.wait_inner();
|
||||||
}
|
}
|
||||||
r => r,
|
r => r,
|
||||||
|
}?;
|
||||||
|
|
||||||
|
// Handle Dovecot's imap_idle_notify_interval message
|
||||||
|
if v.eq_ignore_ascii_case(b"* OK Still here\r\n") {
|
||||||
|
v.clear();
|
||||||
|
} else {
|
||||||
|
break Ok(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue