From: Dave Mitchell Date: Tue, 18 Feb 2003 21:45:45 +0000 (+0000) Subject: Blocking option ignored X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c83a670ef5b88bf7bcdc0857c28022b13bf2106;p=p5sagit%2Fp5-mst-13.2.git Blocking option ignored Date: Tue, 18 Feb 2003 21:45:45 +0000 Message-ID: <20030218214545.C18547@fdgroup.com> and tests for the same: From: Dave Mitchell Date: Wed, 19 Feb 2003 00:42:01 +0000 Message-ID: <20030219004201.F18547@fdgroup.com> p4raw-id: //depot/perl@18748 --- diff --git a/ext/IO/lib/IO/Socket/INET.pm b/ext/IO/lib/IO/Socket/INET.pm index f59c810..7d1c94d 100644 --- a/ext/IO/lib/IO/Socket/INET.pm +++ b/ext/IO/lib/IO/Socket/INET.pm @@ -129,8 +129,6 @@ sub configure { or return _error($sock, $!, $@); } - $sock->blocking($arg->{Blocking}) if defined $arg->{Blocking}; - $proto ||= (getprotobyname('tcp'))[2]; my $pname = (getprotobynumber($proto))[0]; @@ -149,6 +147,11 @@ sub configure { $sock->socket(AF_INET, $type, $proto) or return _error($sock, $!, "$!"); + if (defined $arg->{Blocking}) { + defined $sock->blocking($arg->{Blocking}) + or return _error($sock, $!, "$!"); + } + if ($arg->{Reuse} || $arg->{ReuseAddr}) { $sock->sockopt(SO_REUSEADDR,1) or return _error($sock, $!, "$!"); diff --git a/ext/IO/lib/IO/t/io_sock.t b/ext/IO/lib/IO/t/io_sock.t index c4bfcc4..d91db55 100755 --- a/ext/IO/lib/IO/t/io_sock.t +++ b/ext/IO/lib/IO/t/io_sock.t @@ -29,7 +29,7 @@ BEGIN { } $| = 1; -print "1..20\n"; +print "1..22\n"; eval { $SIG{ALRM} = sub { die; }; @@ -220,12 +220,12 @@ if ( $^O eq 'qnx' ) { # local @data; if( !open( SRC, "< $0")) { - print "not ok 15 - $!"; + print "not ok 15 - $!\n"; } else { @data = ; close( SRC); + print "ok 15\n"; } -print "ok 15\n"; ### TEST 16 ### Start the server @@ -336,6 +336,7 @@ if( $server_pid) { $sock = undef; } $listen->close; + exit 0; } else { @@ -345,3 +346,12 @@ if( $server_pid) { die; } +# test Blocking option in constructor + +$sock = IO::Socket::INET->new(Blocking => 0) + or print "not "; +print "ok 21\n"; + +my $status = $sock->blocking; +print "not " unless defined $status && !$status; +print "ok 22\n";