Subject: | Timeout and external Socket don't cooperate (+trivial fix) |
Hi,
I'm reproducing Debian bug report #401144, as it regards the upstream
code (i.e. your module, not our packaging ;-) ). I'm applying the user
suggested fix in Debian's version. For reference, the bug report URL is:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401144
From: Alexander Zangerl <az@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Timeout and external Socket don't cooperate (+trivial fix)
Date: Fri, 01 Dec 2006 15:17:53 +1000
Package: libmail-imapclient-perl
Version: 2.2.9+deb-2
Severity: normal
If one passes the IMAPClient constructor an external Socket
(eg. when an SSL connection with extra settings is desired), then
the constructor doesn't properly set things up. This fouls operations
if and only if the Timeout parameter is also used, because
the select/timeout code then attempts to access a nonexistent select
fdset.
There's a simple workaround: after making the IMAPClient object,
run $yourobject->Socket($yoursocket). This seems superfluous
(as we can pass the Socket in the constructor more conveniently),
but isn't.
What is going on and how to fix it?
In new(), lines 221++, the parameter values are directly chucked into
the object hash. If connect() would be run (ie. not in our case),
the connection is opened and the _do_accessor() is run for Socket
and this fellow sets up the _select fdset.
But as we pass the external Socket, the _do_accessor() is never run, which
leaves us with no $self->{_select}, which makes the first real operation
bomb with the message
---
Can't call method "can_read" on an undefined value
at /usr/share/perl5/Mail/IMAPClient.pm line 1583.
---
A fix would be to add
$self->Socket($self->{Socket}) if ($self->{Socket});
between lines 235 and 236.
(BTW, a short check of the version in testing shows
that the same problem is present there.)
regards
az