|
|
489d2d |
From 0714c89c318afdc869a6b6e6fe0832dc63cd4ca7 Mon Sep 17 00:00:00 2001
|
|
|
489d2d |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
489d2d |
Date: Mon, 18 Sep 2017 18:22:34 +0200
|
|
|
489d2d |
Subject: [PATCH] Correct prototol family in hints
|
|
|
489d2d |
MIME-Version: 1.0
|
|
|
489d2d |
Content-Type: text/plain; charset=UTF-8
|
|
|
489d2d |
Content-Transfer-Encoding: 8bit
|
|
|
489d2d |
|
|
|
489d2d |
This corrects a warning about undefined protocol passed to Perl
|
|
|
489d2d |
socket() function after applying the fix for a hostless constructor:
|
|
|
489d2d |
|
|
|
489d2d |
$ ./Build test --verbose=1 --test_files t/19no-addrs.t
|
|
|
489d2d |
t/19no-addrs.t ..
|
|
|
489d2d |
ok 1 - $sock->fileno for Family => AF_INET
|
|
|
489d2d |
ok 2 - $sock->sockdomain for Family => AF_INET
|
|
|
489d2d |
ok 3 - $sock->socktype for Family => AF_INET
|
|
|
489d2d |
ok 4 - $sock->fileno for Family => AF_INET6
|
|
|
489d2d |
ok 5 - $sock->sockdomain for Family => AF_INET6
|
|
|
489d2d |
ok 6 - $sock->socktype for Family => AF_INET6
|
|
|
489d2d |
ok 7 - $sock->fileno for Type => SOCK_STREAM
|
|
|
489d2d |
ok 8 - $sock->socktype for Type => SOCK_STREAM
|
|
|
489d2d |
1..8
|
|
|
489d2d |
Use of uninitialized value $protocol in socket at /usr/lib64/perl5/IO/Socket.pm line 81.
|
|
|
489d2d |
ok
|
|
|
489d2d |
All tests successful.
|
|
|
489d2d |
|
|
|
489d2d |
This a port of upstream changes from 0.29 to 0.21 that were described
|
|
|
489d2d |
as:
|
|
|
489d2d |
|
|
|
489d2d |
0.29 2014/02/24 16:06:29
|
|
|
489d2d |
[BUGFIXES]
|
|
|
489d2d |
* Workaround for OSes that disobey AI_ADDRCONFIG and yield AIs on
|
|
|
489d2d |
families the kernel will not support anyway (e.g. HPUX)
|
|
|
489d2d |
|
|
|
489d2d |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
489d2d |
---
|
|
|
489d2d |
lib/IO/Socket/IP.pm | 21 ++++++++++++---------
|
|
|
489d2d |
1 file changed, 12 insertions(+), 9 deletions(-)
|
|
|
489d2d |
|
|
|
489d2d |
diff --git a/lib/IO/Socket/IP.pm b/lib/IO/Socket/IP.pm
|
|
|
489d2d |
index 208d837..bea7d39 100644
|
|
|
489d2d |
--- a/lib/IO/Socket/IP.pm
|
|
|
489d2d |
+++ b/lib/IO/Socket/IP.pm
|
|
|
489d2d |
@@ -521,24 +521,27 @@ sub _configure
|
|
|
489d2d |
if( !@infos ) {
|
|
|
489d2d |
|
|
|
489d2d |
# If there was a Family hint then create a plain unbound, unconnected socket
|
|
|
489d2d |
+ if( defined $hints{family} ) {
|
|
|
489d2d |
+ @infos = ( {
|
|
|
489d2d |
+ family => $hints{family},
|
|
|
489d2d |
+ socktype => $hints{socktype},
|
|
|
489d2d |
+ protocol => $hints{protocol},
|
|
|
489d2d |
+ } );
|
|
|
489d2d |
+ }
|
|
|
489d2d |
# If there wasn't, use getaddrinfo()'s AI_ADDRCONFIG side-effect to guess a
|
|
|
489d2d |
# suitable family first.
|
|
|
489d2d |
- if( !defined $hints{family} ) {
|
|
|
489d2d |
- my ( $err, $addrinfo ) = getaddrinfo( "", "0", \%hints );
|
|
|
489d2d |
+ else {
|
|
|
489d2d |
+ ( my $err, @infos ) = getaddrinfo( "", "0", \%hints );
|
|
|
489d2d |
if( $err ) {
|
|
|
489d2d |
$@ = "$err";
|
|
|
489d2d |
$! = EINVAL;
|
|
|
489d2d |
return;
|
|
|
489d2d |
}
|
|
|
489d2d |
|
|
|
489d2d |
- $hints{family} = $addrinfo->{family};
|
|
|
489d2d |
+ # We'll take all the @infos anyway, because some OSes (HPUX) are known to
|
|
|
489d2d |
+ # ignore the AI_ADDRCONFIG hint and return AF_INET6 even if they don't
|
|
|
489d2d |
+ # support them
|
|
|
489d2d |
}
|
|
|
489d2d |
-
|
|
|
489d2d |
- @infos = ( {
|
|
|
489d2d |
- family => $hints{family},
|
|
|
489d2d |
- socktype => $hints{socktype},
|
|
|
489d2d |
- protocol => $hints{protocol},
|
|
|
489d2d |
- } );
|
|
|
489d2d |
}
|
|
|
489d2d |
|
|
|
489d2d |
# In the nonblocking case, caller will be calling ->setup multiple times.
|
|
|
489d2d |
--
|
|
|
489d2d |
2.13.5
|
|
|
489d2d |
|