Subject: | XML::Stream blocking on SSL connection can_read returns socket but pending returns zero bytes(patch attached) |
Date: | Thu, 02 May 2013 12:58:23 -0600 |
To: | bug-XML-Stream [...] rt.cpan.org |
From: | Allan Oepping <allan [...] oepping.com> |
Distribution: CentOS release 6.4 (Final)
Package name: perl-XML-Stream-1.22-12.el6.noarch
perl, v5.10.1 (*) built for i386-linux-thread-multi
Linux 2.6.32-279.22.1.el6.i686 #1 SMP Wed Feb 6 00:31:03 UTC 2013 i686 i686 i386 GNU/Linux
Workaround: Set $XML::Stream::NONBLOCKING = 1 in caller (Net/XMPP/Connection.pm)
Apparently sockets of type IO::Socket::SSL can be returned from IO::Select::can_read despite no data being readable. It seems that it is permitted for select to return a socket as having data to read
that does not? Otherwise this would be a bug in IO::Socket::SSL.
If the following code is inserted in Stream.pm sub Read() after the call to flush:
my @ready = $self->{SELECT}->can_read(0);
print STDERR "$#ready handle index in Read!!!";
while(my $s = shift(@ready)){
if(ref($s) eq 'IO::Socket::SSL'){
print STDERR "Socket $s: " . ref($s) . ' pending:' . $s->pending() . "\n";
} else {
print STDERR "Socket $s: " . ref($s) . "\n";
}
}
And we use Net::XMPP::Client to connect to:
hostname=talk.google.com
port=5222
componentname=gmail.com
connectiontype=tcpip tls=1
On the AuthSend call it prints:
0 handle index in Read!!!Socket IO::Socket::SSL=GLOB(0x97b9b88): IO::Socket::SSL pending:0
if the line:
$block = 1 if $self->{SELECT}->can_read(0);
on Stream.pm:1482 is replaced with:
my @sl;
$block = 1 if ((@sl = $self->{SELECT}->can_read(0)) && $#sl > -1 && (ref($sl[0]) ne 'IO::Socket::SSL' || $sl[0]->pending() > 0));
It fixes the issue, patch attached
Thanks.
Allan Oepping
Message body is not shown because sender requested not to inline it.