diff options
author | Father Chrysostomos <sprout@cpan.org> | 2009-09-25 13:05:28 -0500 |
---|---|---|
committer | Graham Barr <gbarr@pobox.com> | 2009-09-25 13:05:28 -0500 |
commit | 73dc7393a40391c5cae9d398135813a3bc45df47 (patch) | |
tree | 1be99198aa4dccc2738571a787e7ed94958dfadd | |
parent | 38e09c62b89c2bb112b5271322ce424ceec5087d (diff) | |
download | perl-libnet-73dc7393a40391c5cae9d398135813a3bc45df47.tar.gz |
Avoid long hang on Mac OS X when hostname is *.local by not calling gethostbyname
*.local names are special on darwin. If we call gethostbyname below, it may hang while waiting for another, non-existent computer to respond.
-rw-r--r-- | Net/Domain.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Net/Domain.pm b/Net/Domain.pm index 330909d..017cc92 100644 --- a/Net/Domain.pm +++ b/Net/Domain.pm @@ -16,7 +16,7 @@ use Net::Config; @ISA = qw(Exporter); @EXPORT_OK = qw(hostname hostdomain hostfqdn domainname); -$VERSION = "2.20"; +$VERSION = "2.21"; my ($host, $domain, $fqdn) = (undef, undef, undef); @@ -222,6 +222,13 @@ sub domainname { if (defined $fqdn); _hostname(); + + # *.local names are special on darwin. If we call gethostbyname below, it + # may hang while waiting for another, non-existent computer to respond. + if($^O eq 'darwin' && $host =~ /\.local$/) { + return $host; + } + _hostdomain(); # Assumption: If the host name does not contain a period |