develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [PATCH IO/Socket/INET.pm] Blocking option ignored

Thread Previous
From:
Dave Mitchell
Date:
February 18, 2003 16:45
Subject:
Re: [PATCH IO/Socket/INET.pm] Blocking option ignored
Message ID:
20030219004201.F18547@fdgroup.com
On Tue, Feb 18, 2003 at 10:08:28PM +0000, Nicholas Clark wrote:
> On Tue, Feb 18, 2003 at 09:45:45PM +0000, Dave Mitchell wrote:
> > Currently IO::Socket::INET->new(Blocking => 0, ....)
> > silently fails to set non-blocking, because it attempts to do the fcntl
> > (or whatever) on the socket before the socket's been created. This patch
> > fixes that.
> > (Only tested on Solaris + Linux; I know nothing about those esoteric
>         ^^^^^^
> > OSes from Redmond.)
> 
> Is it possible to write a regression tests for this? Even if it only gets
> run on a whitelist of OSes from $^O that we know behave?

Here's a patch for the regression test - I'd suggest smoking it, then
going back and $^O'ing any OSes that choke on it.

[ The patch also fixes a problemette in the display of failures for
test 15 ]

Dave.

-- 
Never do today what you can put off till tomorrow.


--- ext/IO/lib/IO/t/io_sock.t-	Wed Feb 19 00:38:19 2003
+++ ext/IO/lib/IO/t/io_sock.t	Wed Feb 19 00:41:34 2003
@@ -29,7 +29,7 @@
 }
 
 $| = 1;
-print "1..20\n";
+print "1..22\n";
 
 eval {
     $SIG{ALRM} = sub { die; };
@@ -220,12 +220,12 @@
 #
 local @data;
 if( !open( SRC, "< $0")) {
-    print "not ok 15 - $!";
+    print "not ok 15 - $!\n";
 } else {
     @data = <SRC>;
     close( SRC);
+    print "ok 15\n";
 }
-print "ok 15\n";
 
 ### TEST 16
 ### Start the server
@@ -336,6 +336,7 @@
 	$sock = undef;
     }
     $listen->close;
+    exit 0;
 
 } else {
 
@@ -345,3 +346,12 @@
     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";

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About