Commit 60dd4e8d authored by Bjorn Munch's avatar Bjorn Munch

Bug #43132 Pusbbuild 2 host sol10 sparc64 max is not running tests due to port unavailble

MTR gives up if wanted port not available
Try next range if set to 'auto'
Also, use next number for additional threads if explicitly set
parent 6293a2ea
...@@ -188,6 +188,8 @@ sub mtr_release_unique_id($) { ...@@ -188,6 +188,8 @@ sub mtr_release_unique_id($) {
flock SEM, LOCK_UN or warn "can't unlock $file.sem"; flock SEM, LOCK_UN or warn "can't unlock $file.sem";
close SEM; close SEM;
delete $mtr_unique_ids{$$};
} }
......
...@@ -171,6 +171,7 @@ my $current_config_name; # The currently running config file template ...@@ -171,6 +171,7 @@ my $current_config_name; # The currently running config file template
my $baseport; my $baseport;
my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto"; my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
my $build_thread= 0;
my $opt_record; my $opt_record;
my $opt_report_features; my $opt_report_features;
...@@ -665,14 +666,9 @@ sub run_worker ($) { ...@@ -665,14 +666,9 @@ sub run_worker ($) {
report_option('name',"worker[$thread_num]"); report_option('name',"worker[$thread_num]");
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Use auto build thread in all but first worker # Set different ports per thread
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
set_build_thread_ports($thread_num > 1 ? 'auto' : $opt_build_thread); set_build_thread_ports($thread_num);
if (check_ports_free()){
# Some port was not free(which one has already been printed)
mtr_error("Some port(s) was not free")
}
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Turn off verbosity in workers, unless explicitly specified # Turn off verbosity in workers, unless explicitly specified
...@@ -1268,18 +1264,32 @@ sub command_line_setup { ...@@ -1268,18 +1264,32 @@ sub command_line_setup {
# But a fairly safe range seems to be 5001 - 32767 # But a fairly safe range seems to be 5001 - 32767
# #
sub set_build_thread_ports($) { sub set_build_thread_ports($) {
my $build_thread= shift || 0; my $thread= shift || 0;
if ( lc($build_thread) eq 'auto' ) { if ( lc($opt_build_thread) eq 'auto' ) {
#mtr_report("Requesting build thread... "); my $found_free = 0;
$build_thread= mtr_get_unique_id(250, 299); $build_thread = 250; # Start attempts from here
if ( !defined $build_thread ) { while (! $found_free)
mtr_error("Could not get a unique build thread id"); {
$build_thread= mtr_get_unique_id($build_thread, 299);
if ( !defined $build_thread ) {
mtr_error("Could not get a unique build thread id");
}
$found_free= check_ports_free($build_thread);
# If not free, release and try from next number
mtr_release_unique_id($build_thread++) unless $found_free;
} }
#mtr_report(" - got $build_thread"); }
else
{
$build_thread = $opt_build_thread + $thread - 1;
} }
$ENV{MTR_BUILD_THREAD}= $build_thread; $ENV{MTR_BUILD_THREAD}= $build_thread;
$opt_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;
...@@ -2433,22 +2443,18 @@ sub kill_leftovers ($) { ...@@ -2433,22 +2443,18 @@ sub kill_leftovers ($) {
# Check that all the ports that are going to # Check that all the ports that are going to
# be used are free # be used are free
# #
sub check_ports_free sub check_ports_free ($)
{ {
my @ports_to_check; my $bthread= shift;
for ($baseport..$baseport+9){ my $portbase = $bthread * 10 + 10000;
push(@ports_to_check, $_); for ($portbase..$portbase+9){
} if (mtr_ping_port($_)){
#mtr_report("Checking ports..."); mtr_report(" - 'localhost:$_' was not free");
# print "@ports_to_check\n"; return 0; # One port was not free
foreach my $port (@ports_to_check){
if (mtr_ping_port($port)){
mtr_report(" - 'localhost:$port' was not free");
return 1; # One port was not free
} }
} }
return 0; # All ports free return 1; # All ports free
} }
......
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