Skip Menu |

This queue is for tickets about the IO-Socket-SSL CPAN distribution.

Report information
The Basics
Id: 106573
Status: resolved
Priority: 0/
Queue: IO-Socket-SSL

People
Owner: Nobody in particular
Requestors: AGRUNDMA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 2.006
  • 2.007
  • 2.008
  • 2.009
  • 2.010
  • 2.011
  • 2.012
  • 2.013
  • 2.014
  • 2.015
  • 2.015_001
  • 2.015_002
  • 2.015_003
  • 2.015_004
  • 2.015_005
  • 2.015_006
  • 2.016
  • 2.016_001
  • 2.016_002
Fixed in: (no value)



Subject: [PATCH] Fix failing non-blocking test on Unix platforms where EWOULDBLOCK != EAGAIN.
This bug was introduced by commit d95289 for 2.006. The fix is simply to check for either of these errors instead of just one. I also made a pull request: https://github.com/noxxi/p5-io-socket-ssl/pull/35
Subject: IO-Socket-SSL-2.016-unix-nonblocking.patch
From 58d3aa874ed7467b323a230932cc72564ba7f3b2 Mon Sep 17 00:00:00 2001 From: Andy Grundman <andyg@activestate.com> Date: Thu, 20 Aug 2015 18:09:04 -0700 Subject: [PATCH] Fix failing non-blocking test on Unix platforms where EWOULDBLOCK is not the same as EAGAIN (Solaris, AIX, HP-UX, etc). This bug was introduced by commit d95289 for 2.006. The fix is simply to check for either of these errors instead of just one. --- example/async_https_server.pl | 6 +++--- lib/IO/Socket/SSL.pm | 6 +++--- t/core.t | 4 ++-- t/nonblock.t | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) mode change 100644 => 100755 t/core.t diff --git a/example/async_https_server.pl b/example/async_https_server.pl index 2487a4f..7b7879e 100644 --- a/example/async_https_server.pl +++ b/example/async_https_server.pl @@ -61,7 +61,7 @@ sub _ssl_accept { # setup the client ${*$fdc}{rbuf} = ${*$fdc}{wbuf} = ''; event_new( $fdc, EV_READ, \&_client_read_header )->add; - } elsif ( $! != EWOULDBLOCK ) { + } elsif ( $! != EWOULDBLOCK && $! != EAGAIN ) { die "new client failed: $!|$SSL_ERROR"; } else { DEBUG( "new client need to retry accept: $SSL_ERROR" ); @@ -88,7 +88,7 @@ sub _client_read_header { my $rbuf_ref = \${*$fdc}{rbuf}; my $n = sysread( $fdc,$$rbuf_ref,16384,length($$rbuf_ref)); if ( !defined($n)) { - die $! if $! != EWOULDBLOCK; + die $! if $! != EWOULDBLOCK && $! != EAGAIN; DEBUG( $SSL_ERROR ); if ( $SSL_ERROR == SSL_WANT_WRITE ) { # retry read once I can write @@ -130,7 +130,7 @@ sub _client_write_response { my $fdc = $event->fh; my $wbuf_ref = \${*$fdc}{wbuf}; my $n = syswrite( $fdc,$$wbuf_ref ); - if ( !defined($n) && $! == EWOULDBLOCK) { + if ( !defined($n) && ( $! == EWOULDBLOCK || $! == EAGAIN ) ) { # retry DEBUG( $SSL_ERROR ); if ( $SSL_ERROR == SSL_WANT_READ ) { diff --git a/lib/IO/Socket/SSL.pm b/lib/IO/Socket/SSL.pm index 5943ff5..28ca5ef 100644 --- a/lib/IO/Socket/SSL.pm +++ b/lib/IO/Socket/SSL.pm @@ -19,7 +19,7 @@ use IO::Socket; use Net::SSLeay 1.46; use IO::Socket::SSL::PublicSuffix; use Exporter (); -use Errno qw( EWOULDBLOCK ETIMEDOUT EINTR ); +use Errno qw( EWOULDBLOCK EAGAIN ETIMEDOUT EINTR ); use Carp; use strict; @@ -1111,7 +1111,7 @@ sub readline { my $rv = $self->sysread($buf,2**16,length($buf)); if ( ! defined $rv ) { next if $! == EINTR; # retry - last if $! == EWOULDBLOCK; # use everything so far + last if $! == EWOULDBLOCK || $! == EAGAIN; # use everything so far return; # return error } elsif ( ! $rv ) { last @@ -1141,7 +1141,7 @@ sub readline { my $rv = $self->sysread($buf,$size-length($buf),length($buf)); if ( ! defined $rv ) { next if $! == EINTR; # retry - last if $! == EWOULDBLOCK; # use everything so far + last if $! == EWOULDBLOCK || $! == EAGAIN; # use everything so far return; # return error } elsif ( ! $rv ) { last diff --git a/t/core.t b/t/core.t old mode 100644 new mode 100755 index afef38b..fb2199a --- a/t/core.t +++ b/t/core.t @@ -7,7 +7,7 @@ use warnings; use Net::SSLeay; use Socket; use IO::Socket::SSL; -use Errno 'EWOULDBLOCK'; +use Errno qw( EWOULDBLOCK EAGAIN ); do './testlib.pl' || do './t/testlib.pl' || die "no testlib"; @@ -291,7 +291,7 @@ if ($CAN_NONBLOCK) { $client = $server->accept; while ( ! $client ) { #DEBUG( "$!,$SSL_ERROR" ); - if ( $! == EWOULDBLOCK ) { + if ( $! == EWOULDBLOCK || $! == EAGAIN ) { if ( $SSL_ERROR == SSL_WANT_WRITE ) { IO::Select->new( $server->opening )->can_write(30); } else { diff --git a/t/nonblock.t b/t/nonblock.t index 0e7fc0b..62f2929 100644 --- a/t/nonblock.t +++ b/t/nonblock.t @@ -9,7 +9,7 @@ use Net::SSLeay; use Socket; use IO::Socket::SSL; use IO::Select; -use Errno qw( EWOULDBLOCK EINPROGRESS EPIPE ECONNRESET ); +use Errno qw( EWOULDBLOCK EAGAIN EINPROGRESS EPIPE ECONNRESET ); do './testlib.pl' || do './t/testlib.pl' || die "no testlib"; if ( ! eval "use 5.006; use IO::Select; return 1" ) { @@ -66,7 +66,7 @@ if ( $pid == 0 ) { IO::Select->new( $to_server )->can_write(30) && next; print "not "; last; - } elsif ( $!{EWOULDBLOCK} ) { + } elsif ( $!{EWOULDBLOCK} || $!{EAGAIN} ) { diag( 'connect not yet completed'); # just wait select(undef,undef,undef,0.1); @@ -94,7 +94,7 @@ if ( $pid == 0 ) { while ( $pmsg ne '' ) { my $w = syswrite( $to_server,$pmsg ); if ( ! defined $w ) { - if ( ! $!{EWOULDBLOCK} ) { + if ( ! $!{EWOULDBLOCK} && ! $!{EAGAIN} ) { diag("syswrite failed with $!"); print "not "; last; @@ -197,7 +197,7 @@ if ( $pid == 0 ) { my $n = syswrite( $to_server,$msg,length($msg)-$offset,$offset ); if ( !defined($n) ) { diag( "\$!=$! \$SSL_ERROR=$SSL_ERROR send=$bytes_send" ); - if ( $! == EWOULDBLOCK ) { + if ( $! == EWOULDBLOCK || $! == EAGAIN ) { if ( $SSL_ERROR == SSL_WANT_WRITE ) { diag( 'wait for write' ); $can = 'can_write'; @@ -273,7 +273,7 @@ if ( $pid == 0 ) { my $buf = ''; while ( length($buf) <9 ) { sysread( $from_client, $buf,9-length($buf),length($buf) ) && next; - die "sysread failed: $!" if $! != EWOULDBLOCK; + die "sysread failed: $!" if $! != EWOULDBLOCK && $! != EAGAIN; IO::Select->new( $from_client )->can_read(30); } $buf eq 'plaintext' || print "not "; @@ -350,7 +350,7 @@ if ( $pid == 0 ) { my $n = sysread( $from_client,my $buf,$diff ); if ( !defined($n) ) { diag( "\$!=$! \$SSL_ERROR=$SSL_ERROR" ); - if ( $! == EWOULDBLOCK ) { + if ( $! == EWOULDBLOCK || $! == EAGAIN ) { if ( $SSL_ERROR == SSL_WANT_READ ) { $attempts++; $can = 'can_read'; -- 2.2.1
On Thu Aug 20 21:15:44 2015, AGRUNDMA wrote: Show quoted text
> This bug was introduced by commit d95289 for 2.006. The fix is simply > to check for either of these errors instead of just one. I also made a > pull request: https://github.com/noxxi/p5-io-socket-ssl/pull/35
Thanks for the patch. It will be included in the next release.
closed, fix included.