Subject: | set LastError if a BYE response is received to any command but LOGOUT |
Note this bug is related to the following bugs:
18547 "word too long" using fetch_hash
18376 fetch_hash() fails on large folders (command line too long)
Below is a snippet from a log/trace of an IMAP session:
Sending: 59 UID FETCH 3418,3602,3605,...(lots
more)...,36772:36774,36782:36783 BODY.PEEK[HEADER]
Sent 17313 bytes
Read: * BYE [ALERT] Fatal error: max atom size too small: No such file
or directory
This example is apparently from courier-imap which defines this
arbitrary limit to command/request length:
/* ATOMS have the following maximum length */
#define IT_MAX_ATOM_SIZE 16384
Per RFC 3501 (http://www.faqs.org/rfcs/rfc3501.html) secton 7.1.5 "BYE
Response"
...The BYE response is sent under one of four conditions:
1) as part of a normal logout sequence. The server will close
the connection after sending the tagged OK response to the
LOGOUT command.
2) as a panic shutdown announcement. The server closes the
connection immediately.
3) as an announcement of an inactivity autologout. The server
closes the connection immediately.
4) as one of three possible greetings at connection startup,
indicating that the server is not willing to accept a
connection from this client. The server closes the
connection immediately.
The difference between a BYE that occurs as part of a normal
LOGOUT sequence (the first case) and a BYE that occurs because of
a failure (the other three cases) is that the connection closes
immediately in the failure case.
Given that 2,3,4 are considered failure cases we should set LastError if
we receive a BYE that does not come from a LOGOUT command. Here's a
simple patch that should support this:
$ diff -u IMAPClient.pm.LATEST IMAPClient.pm
--- IMAPClient.pm.ORIG 2009-02-24 16:29:24.000000000 -0500
+++ IMAPClient.pm 2009-04-02 14:52:04.000000000 -0400
@@ -1136,6 +1136,7 @@
if($o->[DATA] =~ /^\*\s+BYE/im)
{ $self->State(Unconnected);
+ $self->LastError($o->[DATA]) unless ($string =~
/^LOGOUT/i);
return undef;
}
}