Subject: | IO::Socket::SSL 2.006 changes EAGAIN to EWOULDBLOCK which breaks Net::HTTP 6.07 |
Date: | Thu, 27 Nov 2014 15:38:44 -0000 |
To: | <bug-Net-HTTP [...] rt.cpan.org> |
From: | "Peter Stokes" <peter [...] dadeos.co.uk> |
Hi,
I am using IO-Socket-SSL-2.007 together with Net-HTTP-6.07 (and
libwww-perl-6.08) on Perl 5.20.1 for Windows and am receiving "read failed:
A non-blocking socket operation could not be completed immediately." errors.
I believe that these errors are the result of a modification made to
IO::Socket::SSL in version 2.006 that changed some errors from "EAGAIN" to
"EWOULDBLOCK", which have different values on Windows (see:
https://github.com/noxxi/p5-io-socket-ssl/commit/d95289de02ca9aede1c4f86481e
8fd1daa10cc7d).
I'm afraid that I am not particularly familiar with the internals of
Net::HTTP (and LWP) but modifying the checks for "EAGAIN" to check for both
"EAGAIN" and "EWOULDBLOCK" resolve the particular issue that I am
encountering.
Thanks
Peter
--- lib\Net\HTTP\Methods.pm.orig 2014-07-24 04:27:26.000000000 -0000
+++ lib\Net\HTTP\Methods.pm 2014-11-27 15:23:57.000000000 -0000
@@ -267,13 +267,13 @@
# need to read more data to find a line ending
READ:
{
die "read timeout" unless $self->can_read;
my $n = $self->sysread($_, 1024, length);
unless (defined $n) {
- redo READ if $!{EINTR} || $!{EAGAIN};
+ redo READ if $!{EINTR} || $!{EAGAIN} ||
$!{EWOULDBLOCK};
# if we have already accumulated some data let's at
least
# return that as a line
die "$what read failed: $!" unless length;
}
unless ($n) {
return undef unless length;
--- lib\LWP\Protocol\http.pm.orig 2014-07-25 04:13:08.000000000 -0000
+++ lib\LWP\Protocol\http.pm 2014-11-27 15:07:36.000000000 -0000
@@ -460,13 +460,13 @@
my $buf = ""; #prevent use of uninitialized value in SSLeay.xs
my $n;
READ:
{
$n = $socket->read_entity_body($buf, $size);
unless (defined $n) {
- redo READ if $!{EINTR} || $!{EAGAIN} || $!{ENOTTY};
+ redo READ if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK} ||
$!{ENOTTY};
die "read failed: $!";
}
redo READ if $n == -1;
}
$complete++ if !$n;
return \$buf;