Skip Menu |

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

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

People
Owner: PLOBBES [...] cpan.org
Requestors: mas [...] scsy.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 3.25
  • 3.26
  • 3.27
  • 3.28
Fixed in: 3.29



Subject: Socket no longer blocking after being passed to Mail::IMAPClient
I had a report from a user of my Script GhettoPush https://github.com/mschmitt/GhettoPush (which converts IDLE updates to iPhone push messages) that he can't use it on Debian Squeeze. Squeeze has a packaged Mail::IMAPClient 3.25 but I have developed my Script 2 years ago on 3.18, which is what I still have installed on my Debian system from CPAN. The script opens a socket first and hands it to Mail::IMAPClient for further use. Some testing turns up that 3.25 and 3.28 convert this socket into a non-blocking socket, which is why waiting for messages in the IDLE session fails. Due to the non-blocking socket, the script does not wait for data from the socket and fails miserably. I would rather not refactor my script to use the new idle_data function as I do not want to lose backwards compatibility. Can you let me know why the socket isn't blocking anymore after being used by Mail::IMAPClient? Is this intended behaviour? How can it be undone? Is there a Workaround? Sample script. Mail::IMAPClient 3.28 is in /home/martin/perllib, Mail::IMAPClient 3.18 is in /usr/local/lib/perl/whatever. If using Version 3.18, the script blocks at the read attempt, as expected: #!/usr/bin/perl -w use strict; use diagnostics; #use lib qw(/home/martin/perllib); use IO::Socket::INET; use Mail::IMAPClient; my $socket = IO::Socket::INET->new( PeerAddr => '127.0.0.1', PeerPort => 143, Timeout => 30 ); unless ($socket){ die "Connection failed.\n"; } my $imap = Mail::IMAPClient->new( Socket => $socket, Timeout => 60 ); <$socket>; print "If you can read this, the socket is not blocking.\n";
Workaround: $socket->blocking(1); while (<$socket>) { # wait for IDLE updates }; That fixes it nicely, but I still wonder why Mail::IMAPClient behaves like this. Is my workaround breaking any other functionality?
The behavior changed due to a typo being fixed. The typo was: sub Fast_io(;$) { my ( $self, $use ) = @_; defined $use - or return $self->{File_io}; + or return $self->{Fast_io}; However, I do believe that if you provide your own socket Mail::IMAPClient shouldn't change the blocking/non-blocking behavior of the socket. I'll fix this behavior in the next release, which I hope to have out within a few weeks. Thanks for reporting this bug!
Thanks for the feedback! :-)
Mail::IMAPClient 3.29 was released today with the patch for this bug, please feel free to reopen if you find the problem still exists in this release.