Since IO::Socket::UNIX is part of core perl, it's not enough to

"eval use" it. Instead trap the error that occurs when creating the socket
on platforms that does not support it. 
parent fdf1376a
...@@ -51,15 +51,6 @@ BEGIN { ...@@ -51,15 +51,6 @@ BEGIN {
} }
} }
BEGIN {
if (eval "use IO::Socket::UNIX; 1") {
eval 'sub HAVE_UNIX_SOCKET { 1 }';
}
else {
eval 'sub HAVE_UNIX_SOCKET { 0 }';
}
}
# #
# native_path # native_path
...@@ -105,27 +96,27 @@ sub check_socket_path_length { ...@@ -105,27 +96,27 @@ sub check_socket_path_length {
my ($path)= @_; my ($path)= @_;
my $truncated= 0; my $truncated= 0;
if (HAVE_UNIX_SOCKET){ require IO::Socket::UNIX;
require IO::Socket::UNIX;
my $sock = new IO::Socket::UNIX
my $sock = new IO::Socket::UNIX (
( Local => $path,
Local => $path, Listen => 1,
Listen => 1, );
) or die $!; if (!defined $sock){
if ($path ne $sock->hostpath()){ # Could not create a UNIX domain socket
# Path was truncated return 0; # Ok, will not be used by mysqld either
$truncated= 1; }
# Output diagnostic messages if ($path ne $sock->hostpath()){
print "path: '$path', length: ", length($path) ,"\n"; # Path was truncated
print "hostpath: '", $sock->hostpath(), $truncated= 1;
"', length: ", length($sock->hostpath()), "\n"; # Output diagnostic messages
} print "path: '$path', length: ", length($path) ,"\n";
$sock= undef; print "hostpath: '", $sock->hostpath(),
unlink($path); "', length: ", length($sock->hostpath()), "\n";
return $truncated; }
}; $sock= undef; # Close socket
# All paths OK! unlink($path); # Remove the physical file
return $truncated; return $truncated;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment