Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO::Socket::SSL 2.006 changes EAGAIN to EWOULDBLOCK which breaks Net::HTTP 6.07 [rt.cpan.org #100580] #32

Open
oalders opened this issue Mar 30, 2017 · 0 comments

Comments

@oalders
Copy link
Member

oalders commented Mar 30, 2017

Migrated from rt.cpan.org#100580 (status was 'new')

Requestors:

From peter@dadeos.co.uk on 2014-11-27 15:38:59:

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant