PaulHowarth/Blog/2008-09-25

Thursday 25th September 2008

Local Packages

  • Updated perl-IO-Socket-INET6 to 2.55

I found that the test suite for this package failed on Fedora 9 and Rawhide.

+ make test TEST_VERBOSE=1
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" t/*.t
t/configure6........
1..1
ok 1 - Testing that "sub configure" does not fail
ok
t/host6.............
1..4
ok 1 - Checking for sockhost() success
Can't call method "peerhost" on an undefined value at t/host6.t line 63.
 Failed 3/4 subtests
Use of uninitialized value $sock in <HANDLE> at t/host6.t line 50.
readline() on unopened filehandle at t/host6.t line 50.

It was the same on the previous version, currently in Fedora - the Fedora package has the test suite disabled.

I discovered that in Fedora >= 9, creating sockets bound to ::1 can be unreliable if the address family isn't explicitly set to AF_INET6, and a "bind: invalid argument" error can result. This patch got the test suite working reliably:

--- IO-Socket-INET6-2.54/t/host6.t      2008-02-22 10:59:34.000000000 +0000
+++ IO-Socket-INET6-2.54/t/host6.t      2008-09-25 12:06:01.000000000 +0100
@@ -37,6 +37,7 @@
                                # some systems seem to need as much as 10,
                                # so be generous with the timeout
                                Timeout => 15,
+                               Domain => AF_INET6,
                               ) or die "$@";
 
 # TEST
@@ -54,7 +55,7 @@
 
     plan tests => 4;
     # child, try various ways to connect
-    my $sock = IO::Socket::INET6->new("[::1]:$port");
+    my $sock = IO::Socket::INET6->new(PeerAddr => "[::1]:$port", Domain => AF_INET6) or die "Can't create socket: $@\n";
 
     # TEST
     ok ($sockhost, "Checking for sockhost() success");
--- IO-Socket-INET6-2.54/t/io_sock6.t   2008-09-25 12:16:38.000000000 +0100
+++ IO-Socket-INET6-2.54/t/io_sock6.t   2008-09-25 12:30:40.000000000 +0100
@@ -107,7 +107,7 @@
 
 # Test various other ways to create INET sockets that should
 # also work.
-$listen = IO::Socket::INET6->new(Listen => '', Timeout => 15) or die "$@";
+$listen = IO::Socket::INET6->new(Listen => '', Timeout => 15, Domain => AF_INET6) or die "$@";
 $port = $listen->sockport;
 
 if($pid = fork()) {
@@ -147,7 +147,9 @@
     # some machines seem to suffer from a race condition here
     sleep(2);
 
-    $sock = IO::Socket::INET6->new("[::1]:$port");
+    # Forcing Domain => AF_INET6 here makes this the same as the next test but
+    # I get "bind: invalid argument" without it...
+    $sock = IO::Socket::INET6->new(PeerAddr => "[::1]:$port", Domain => AF_INET6);
     if ($sock) {
        $sock->print("ok 10\n");
        $sock->print("done\n");

I don't know though whether the real problem here is the test suite, Fedora's perl, or something even lower level in Fedora.


Recent