mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug #44530 mtr v2 startup very slow on Windows.
MTR is stuck for about 20 seconds checking for free ports. The reason is that perl's connect() takes 1 second on windows if port is not opened. This patch fixes the mtr_ping_port implementation on Windows to use Net::Ping for the port checking with small (0.1sec) timeout. This patch also removes pointless second call to check_ports_free() in case of auto build thread.
This commit is contained in:
@ -21,6 +21,9 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use Socket;
|
use Socket;
|
||||||
use Errno;
|
use Errno;
|
||||||
|
use My::Platform;
|
||||||
|
use if IS_WINDOWS, "Net::Ping";
|
||||||
|
|
||||||
|
|
||||||
sub sleep_until_file_created ($$$);
|
sub sleep_until_file_created ($$$);
|
||||||
sub mtr_ping_port ($);
|
sub mtr_ping_port ($);
|
||||||
@ -30,6 +33,25 @@ sub mtr_ping_port ($) {
|
|||||||
|
|
||||||
mtr_verbose("mtr_ping_port: $port");
|
mtr_verbose("mtr_ping_port: $port");
|
||||||
|
|
||||||
|
if (IS_WINDOWS)
|
||||||
|
{
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtr_verbose("FREE");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $remote= "localhost";
|
my $remote= "localhost";
|
||||||
my $iaddr= inet_aton($remote);
|
my $iaddr= inet_aton($remote);
|
||||||
if ( ! $iaddr )
|
if ( ! $iaddr )
|
||||||
|
@ -1344,14 +1344,13 @@ sub set_build_thread_ports($) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$build_thread = $opt_build_thread + $thread - 1;
|
$build_thread = $opt_build_thread + $thread - 1;
|
||||||
|
if (! check_ports_free($build_thread)) {
|
||||||
|
# Some port was not free(which one has already been printed)
|
||||||
|
mtr_error("Some port(s) was not free")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$ENV{MTR_BUILD_THREAD}= $build_thread;
|
$ENV{MTR_BUILD_THREAD}= $build_thread;
|
||||||
|
|
||||||
if (! check_ports_free($build_thread)) {
|
|
||||||
# Some port was not free(which one has already been printed)
|
|
||||||
mtr_error("Some port(s) was not free")
|
|
||||||
}
|
|
||||||
|
|
||||||
# Calculate baseport
|
# Calculate baseport
|
||||||
$baseport= $build_thread * 10 + 10000;
|
$baseport= $build_thread * 10 + 10000;
|
||||||
if ( $baseport < 5001 or $baseport + 9 >= 32767 )
|
if ( $baseport < 5001 or $baseport + 9 >= 32767 )
|
||||||
|
Reference in New Issue
Block a user