diff options
author | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-05-08 01:10:53 +0200 |
---|---|---|
committer | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-05-08 01:10:53 +0200 |
commit | 9e9d9bf9d7884b956455c46f5308205d85d5b130 (patch) | |
tree | c4e97fd92aa047ce96d1c5c88f9bddad06036945 | |
parent | cf1845f4da8ae1208ca3da8e83329784099ae4f6 (diff) | |
download | mariadb-git-9e9d9bf9d7884b956455c46f5308205d85d5b130.tar.gz |
Fix regression on pushbuild 1. The cygwin perl is ancient there, and Net::Ping does not have port_number method (port_number was introduced around 2007). The fix is to check if port_number is present. Otherwise, fallback to the slow connect().
-rw-r--r-- | mysql-test/lib/mtr_process.pl | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 25bbce84ab3..a42627c93cd 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -24,7 +24,22 @@ use Errno; use My::Platform; use if IS_WINDOWS, "Net::Ping"; - +# Ancient perl might not have port_number method for Net::Ping. +# Check it and use fallback to connect() if it is not present. +BEGIN +{ + my $use_netping= 0; + if (IS_WINDOWS) + { + my $ping = Net::Ping->new(); + if ($ping->can("port_number")) + { + $use_netping= 1; + } + } + eval 'sub USE_NETPING { $use_netping }'; +} + sub sleep_until_file_created ($$$); sub mtr_ping_port ($); @@ -33,22 +48,21 @@ sub mtr_ping_port ($) { mtr_verbose("mtr_ping_port: $port"); - if (IS_WINDOWS) + if (IS_WINDOWS && USE_NETPING) { # Under Windows, connect to a port that is not open is slow # It takes ~1sec. Net::Ping with small timeout is much faster. my $ping = Net::Ping->new(); $ping->port_number($port); - if ($ping->ping("localhost",0.1)) { - mtr_verbose("USED"); - return 1; + mtr_verbose("USED"); + return 1; } else { - mtr_verbose("FREE"); - return 0; + mtr_verbose("FREE"); + return 0; } } |