From ac0b54f66b2dba01cd478fe9115e102db76f13d8 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 10 Mar 2008 18:05:26 +0000 Subject: [PATCH] Make the INET6 support check more direct and to the point git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@744 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Client.pm | 19 +++++++++++-------- xCAT-server-2.0/sbin/xcatd | 26 +++++++++++++++----------- xCAT-server-2.0/xCAT-server.spec | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Client.pm b/perl-xCAT-2.0/xCAT/Client.pm index 1ab4de902..b69398b5d 100644 --- a/perl-xCAT-2.0/xCAT/Client.pm +++ b/perl-xCAT-2.0/xCAT/Client.pm @@ -10,15 +10,18 @@ use xCAT::NodeRange; use xCAT::Utils; use xCAT::Table; +my $inet6support; use IO::Socket::SSL; -if (xCAT::Utils->isLinux()) { - eval { require Socket6 }; - eval { require IO::Socket::INET6 }; - eval { require IO::Socket::SSL::inet6 }; -} else { - - eval { require Socket }; - eval { require IO::Socket::INET }; +$inet6support=eval { require Socket6 }; +if ($inet6support) { + $inet6support = eval { require IO::Socket::INET6 }; +} +if ($inet6support) { + $inet6support = eval { require IO::Socket::SSL::inet6 }; +} +unless ($inet6support) { + eval { require Socket }; + eval { require IO::Socket::INET }; } use XML::Simple; diff --git a/xCAT-server-2.0/sbin/xcatd b/xCAT-server-2.0/sbin/xcatd index 61f08da64..b84e263c1 100755 --- a/xCAT-server-2.0/sbin/xcatd +++ b/xCAT-server-2.0/sbin/xcatd @@ -13,13 +13,17 @@ use Thread qw(yield); use xCAT::Client submit_request; use IO::Socket::SSL; -if (xCAT::Utils->isLinux()) { - eval { require Socket6 }; - eval { require IO::Socket::INET6 }; - eval { require IO::Socket::SSL::inet6 }; -} else { - eval { require Socket }; - eval { require IO::Socket::INET }; +my $inet6support; +$inet6support=eval { require Socket6 }; +if ($inet6support) { + $inet6support = eval { require IO::Socket::INET6 }; +} +if ($inet6support) { + $inet6support = eval { require IO::Socket::SSL::inet6 }; +} +unless ($inet6support) { + eval { require Socket }; + eval { require IO::Socket::INET }; } my $dispatch_requests = 1; # govern whether commands are dispatchable @@ -103,7 +107,7 @@ sub do_installm_service { #This function servers as a handler for messages from installing nodes my $socket; -if (xCAT::Utils->isLinux()) { +if ($inet6support) { $socket = IO::Socket::INET6->new(LocalPort=>$sport, Proto => 'tcp', ReuseAddr => 1, @@ -125,7 +129,7 @@ if (xCAT::Utils->isLinux()) { next unless $conn = $socket->accept; my @clients; -if (xCAT::Utils->isLinux()) { +if ($inet6support) { @clients = gethostbyaddr($conn->peeraddr,AF_INET6); } else { @clients = gethostbyaddr($conn->peeraddr,AF_INET); @@ -228,7 +232,7 @@ sub do_udp_service { #This function opens up a UDP port $dispatch_requests=0; my $socket; my $select = new IO::Select; -if (xCAT::Utils->isLinux()) { +if ($inet6support) { $socket = IO::Socket::INET6->new(LocalPort => $port, Proto => 'udp', Domain => AF_INET); @@ -401,7 +405,7 @@ until ($quit) { } $sitetab->close; -if (xCAT::Utils->isLinux()) { +if ($inet6support) { $peerhost = gethostbyaddr($connection->peeraddr,AF_INET6); } else { $peerhost = gethostbyaddr($connection->peeraddr,AF_INET); diff --git a/xCAT-server-2.0/xCAT-server.spec b/xCAT-server-2.0/xCAT-server.spec index 69a1da518..82f7104f4 100644 --- a/xCAT-server-2.0/xCAT-server.spec +++ b/xCAT-server-2.0/xCAT-server.spec @@ -15,7 +15,7 @@ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root # also need to fix Requires for AIX %ifos linux BuildArch: noarch -Requires: perl-IO-Socket-SSL perl-XML-Simple perl-IO-Socket-INET6 +Requires: perl-IO-Socket-SSL perl-XML-Simple %endif Requires: perl-xCAT = %{version}