summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/Platform.pm
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.mysql.com>2008-04-22 12:43:38 +0200
committerunknown <msvensson@pilot.mysql.com>2008-04-22 12:43:38 +0200
commit1737e14c966ec2eac283c2a7e08328283daa15d4 (patch)
treeda85271b7a97fd8b869120d833a0b0a6b74296d1 /mysql-test/lib/My/Platform.pm
parent079fa53f45e7fa8e20c3d8fbf996fa57b9364772 (diff)
downloadmariadb-git-1737e14c966ec2eac283c2a7e08328283daa15d4.tar.gz
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.
Diffstat (limited to 'mysql-test/lib/My/Platform.pm')
-rw-r--r--mysql-test/lib/My/Platform.pm51
1 files changed, 21 insertions, 30 deletions
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index a70f6bb2359..bcd2401423d 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -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
@@ -105,27 +96,27 @@ sub check_socket_path_length {
my ($path)= @_;
my $truncated= 0;
- if (HAVE_UNIX_SOCKET){
- require IO::Socket::UNIX;
-
- my $sock = new IO::Socket::UNIX
- (
- Local => $path,
- Listen => 1,
- ) or die $!;
- if ($path ne $sock->hostpath()){
- # Path was truncated
- $truncated= 1;
- # Output diagnostic messages
- print "path: '$path', length: ", length($path) ,"\n";
- print "hostpath: '", $sock->hostpath(),
- "', length: ", length($sock->hostpath()), "\n";
- }
- $sock= undef;
- unlink($path);
- return $truncated;
- };
- # All paths OK!
+ require IO::Socket::UNIX;
+
+ my $sock = new IO::Socket::UNIX
+ (
+ Local => $path,
+ Listen => 1,
+ );
+ if (!defined $sock){
+ # Could not create a UNIX domain socket
+ return 0; # Ok, will not be used by mysqld either
+ }
+ if ($path ne $sock->hostpath()){
+ # Path was truncated
+ $truncated= 1;
+ # Output diagnostic messages
+ print "path: '$path', length: ", length($path) ,"\n";
+ print "hostpath: '", $sock->hostpath(),
+ "', length: ", length($sock->hostpath()), "\n";
+ }
+ $sock= undef; # Close socket
+ unlink($path); # Remove the physical file
return $truncated;
}