Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 60045
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: PLOBBES [...] cpan.org
Requestors: bitcard [...] wolfermann.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.25
Fixed in: 3.26



Subject: Logout not working if server answers with two separate lines
Using example from the documentation: $imap->logout or die "Logout error:", $imap->LastError, "\n"; Logout with Gmail: Sending: 32 LOGOUT Sent 11 bytes Read: * BYE LOGOUT Requested 32 OK 73 good day (Success) Works. Logout with Dovecot: Sending: 5 LOGOUT Sent 10 bytes Read: * BYE Logging out Read: 5 OK Logout completed. Application will always die with "Logout error: * BYE Logging out". Possible solution: --- IMAPClient.pm.orig Tue Aug 3 17:51:00 2010 +++ IMAPClient.pm Tue Aug 3 17:53:30 2010 @@ -1456,7 +1456,7 @@ $code = uc($1); $self->LastError($data) unless ( $code eq 'OK' ); } - elsif ( $data =~ /^\*\s+(BYE)\b/i ) { + elsif ( not exists $self->{IGNORE_BYE} and $data =~ /^\*\s+(BYE)\b/i ) { $code = uc($1); $byemsg = $data; } @@ -1922,7 +1922,9 @@ sub logout { my $self = shift; + $self->{IGNORE_BYE} = 1; my $rc = $self->_imap_command("LOGOUT"); + delete $self->{IGNORE_BYE}; $self->_disconnect; return $rc; }
Thanks for the report. I've left this behavior as-is for a little while, but I think we can perhaps just make it smarter and not care about semantics of how the server should behave. I'll see if I can put in a nicer behavior in the next release although I think I may do it just by tweaking the behavior in the logout method itself instead of passing a flag around. We'll see. Either way, thanks for taking the time to report this issue!
I have just checked in a patch to git (https://sourceforge.net/p/mail- imapclient/git/) that will loosen the error handling around LOGOUT. It turns out that the problem really is because of a slight delay between the * BYE and the <tag> OK by dovecot. At this point, there doesn't seem to be much benefit in double checking for more date to read from the socket after we get the * BYE and the initial read does not return any more data. We'll stick with this hack for now and maybe some day do something more elegant.
Mail::IMAPClient 3.26 has been released to CPAN. Please install it if you get a chance and let me know if you run into any more problems, thanks!