This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Minor bugfixes to Socket::getaddrinfo
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>
Tue, 8 Feb 2011 18:36:40 +0000 (18:36 +0000)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Tue, 8 Feb 2011 20:24:41 +0000 (21:24 +0100)
Attached are two small bugfixes to getaddrinfo()

Please apply,

Thanks.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

From 61fdece8ab9a729206f2633f47e25afd6f05af6a Mon Sep 17 00:00:00 2001
From: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
Date: Mon, 24 Jan 2011 18:58:40 +0000
Subject: [PATCH 2/3] canonname should only be present on the first returned result

Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
ext/Socket/Socket.pm
ext/Socket/Socket.xs

index 509eb26..252bb00 100644 (file)
@@ -282,7 +282,8 @@ The address in a packed string (such as would be returned by pack_sockaddr_in)
 =item canonname => STRING
 
 The canonical name for the host if the C<AI_CANONNAME> flag was provided, or
-C<undef> otherwise.
+C<undef> otherwise. This field will only be present on the first returned
+address.
 
 =back
 
@@ -736,11 +737,16 @@ sub fake_getaddrinfo
                socktype  => $socktype,
                protocol  => $protocol,
                addr      => Socket::pack_sockaddr_in( $port, $addr ),
-               canonname => $canonname,
+               canonname => undef,
            };
        }
     }
 
+    # Only supply canonname for the first result
+    if( defined $canonname ) {
+       $ret[0]->{canonname} = $canonname;
+    }
+
     return ( fake_makeerr( 0 ), @ret );
 }
 
index 0dda808..e9a8c56 100644 (file)
@@ -292,6 +292,7 @@ static void xs_getaddrinfo(pTHX_ CV *cv)
        }
 
        Zero(&hints_s, sizeof hints_s, char);
+       hints_s.ai_family = PF_UNSPEC;
 
        if(hints && SvOK(hints)) {
                HV *hintshash;