Subject: | Net::LDAP 'process' method blocking in Async mode |
Date: | Fri, 07 Jun 2013 07:53:15 +0100 |
To: | bug-perl-ldap [...] rt.cpan.org |
From: | Christophe Wolfhugel <chris [...] wolfhugel.eu> |
I do think following is a bug in 0.55 (and earlier), as this code
would block on the first loop:
sub process {
my $ldap = shift;
my $what = shift;
my $sock = $ldap->socket or return LDAP_SERVER_DOWN;
my $sel = IO::Select->new($sock);
my $ready;
for ($ready = 1 ; $ready ; $ready = $sel->can_read(0) || (ref($sock) eq 'IO::Socket::SSL' && $sock->pending())) {
my $pdu;
asn_read($sock, $pdu)
or return _drop_conn($ldap, LDAP_OPERATIONS_ERROR, 'Communications Error');
When calling the process method, asn_read will always be called on the
first loop, eventually blocking the process even if no messages are
available.
I would believe that the loop could/should be tried as something similar to:
while (defined $sel->can_read(0) || (ref($sock) eq 'IO::Socket::SSL' && $sock->pending())) {
...
}
Now the question here is what should 'compare' return when nothing is
ready? undef? Any LDAP_ error code to indicate nothing available?
--
Christophe Wolfhugel -+- chris@wolfhugel.eu