Find ndb binaries

Verbose SafeProcess.pm 


mysql-test/mysql-test-run.pl:
  Cleanup how script find ndb binaries and paths
  Remove "executable_setup_failed" code, i.e either we have ndb support or we don't
  Remove ndb_extra_test, not used by any test. If there is a need for that, just 
  create a new suite
mysql-test/lib/My/Find.pm:
  Add possibility to use my_find_bin for a binary that is not required
mysql-test/lib/My/SafeProcess.pm:
  Add verbose printous that can be turned on
  Wait on process also if start_kill failed
  Turn verbose on for windows
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
  Extend sleep from 0 to 100
mysql-test/lib/mtr_cases.pm:
  Remove ndb_extra
mysql-test/suite/rpl_ndb/t/rpl_ndb_circular.test:
  Extra checks should be for Last_IO_Errno
This commit is contained in:
unknown 2008-03-13 17:16:42 +01:00
commit 24640ab982
6 changed files with 93 additions and 128 deletions

View file

@ -26,12 +26,15 @@ use Carp;
use My::Platform;
use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir);
our @EXPORT= qw(my_find_bin my_find_dir NOT_REQUIRED);
our $vs_config_dir;
my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions
sub NOT_REQUIRED { return 0; }
#
# my_find_bin - find an executable with "name_1...name_n" in
# paths "path_1...path_n" and return the full path
@ -44,13 +47,21 @@ my $bin_extension= ".exe" if IS_WINDOWS;
# ["client", "bin"],
# "mysql");
#
#
# To check if something exists, use the required parameter
# set to 0, the function will return an empty string if the
# binary is not found
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql", 0);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_bin {
my ($base, $paths, $names)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>)"
unless @_ == 3;
my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>, [<required>])"
unless @_ == 4 or @_ == 3;
# -------------------------------------------------------
# Find and return the first executable
@ -58,6 +69,10 @@ sub my_find_bin {
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
return $path if ( -x $path or (IS_WINDOWS and -f $path) );
}
if (defined $required and $required == NOT_REQUIRED){
# Return empty string to indicate not found
return "";
}
find_error($base, $paths, $names);
}
@ -79,7 +94,7 @@ sub my_find_bin {
#
#
sub my_find_dir {
my ($base, $paths, $dirs)= @_;
my ($base, $paths, $dirs, $required)= @_;
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
unless (@_ == 3 or @_ == 2);

View file

@ -59,6 +59,7 @@ use My::Find;
use My::Platform;
my %running;
my $_verbose= IS_WINDOWS;
END {
# Kill any children still running
@ -85,33 +86,17 @@ if (IS_WIN32PERL or IS_CYGWIN){
# Use my_safe_process.exe
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
die "Could not find my_safe_process" unless $exe;
push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
die "Could not find my_safe_kill" unless $safe_kill;
}
else
{
my $use_safe_process_binary= 1;
if ($use_safe_process_binary) {
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
die "Could not find my_safe_process" unless $exe;
push(@safe_process_cmd, $exe);
}
else
{
# Use safe_process.pl
my $script= "lib/My/SafeProcess/safe_process.pl";
$script= "../$script" unless -f $script;
die "Could not find safe_process.pl" unless -f $script;
# Call $script with Perl interpreter
push(@safe_process_cmd, $^X, $script);
}
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}
@ -248,14 +233,14 @@ sub timer {
sub shutdown {
my $shutdown_timeout= shift;
my @processes= @_;
_verbose("shutdown, timeout: $shutdown_timeout, @processes");
return if (@processes == 0);
#print "shutdown: @processes\n";
# Call shutdown function if process has one, else
# use kill
foreach my $proc (@processes){
_verbose(" proc: $proc");
my $shutdown= $proc->{SAFE_SHUTDOWN};
if ($shutdown_timeout > 0 and defined $shutdown){
$shutdown->();
@ -301,7 +286,7 @@ sub shutdown {
sub start_kill {
my ($self)= @_;
croak "usage: \$safe_proc->start_kill()" unless (@_ == 1 and ref $self);
#print "start_kill $self\n";
_verbose("start_kill: $self");
my $ret= 1;
if (defined $safe_kill and $self->{SAFE_WINPID}){
@ -309,6 +294,7 @@ sub start_kill {
# it's time to kill it's child and return
my $pid= $self->{SAFE_WINPID};
$ret= (system($safe_kill, $pid) >> 8) == 0;
print `tasklist` unless $ret;
} else {
my $pid= $self->{SAFE_PID};
die "Can't kill not started process" unless defined $pid;
@ -327,10 +313,8 @@ sub kill {
my ($self)= @_;
croak "usage: \$safe_proc->kill()" unless (@_ == 1 and ref $self);
if ($self->start_kill())
{
$self->wait_one();
}
$self->start_kill();
$self->wait_one();
return 1;
}
@ -338,8 +322,8 @@ sub kill {
sub _collect {
my ($self)= @_;
#print "_collect\n";
$self->{EXIT_STATUS}= $?;
_verbose("_collect: $self");
# Take the process out of running list
my $pid= $self->{SAFE_PID};
@ -363,15 +347,17 @@ sub wait_one {
my ($self, $timeout)= @_;
croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self;
#print "wait_one $self, $timeout\n";
_verbose("wait_one $self, $timeout");
if ( ! defined($self->{SAFE_PID}) ) {
# No pid => not running
_verbose("No pid => not running");
return 0;
}
if ( defined $self->{EXIT_STATUS} ) {
# Exit status already set => not running
_verbose("Exit status already set => not running");
return 0;
}
@ -400,6 +386,7 @@ sub wait_one {
$blocking= 1;
$use_alarm= 0;
}
#_verbose("blocking: $blocking, use_alarm: $use_alarm");
my $retpid;
eval
@ -419,18 +406,22 @@ sub wait_one {
die "Got unexpected: $@" if ($@ !~ /waitpid timeout/);
if (!defined $retpid) {
# Got timeout
_verbose("Got timeout");
return 1;
}
# Got pid _and_ alarm, continue
_verbose("Got pid and alarm, continue");
}
if ( $retpid == 0 ) {
# 0 => still running
_verbose("0 => still running");
return 1;
}
if ( not $blocking and $retpid == -1 ) {
# still running
_verbose("still running");
return 1;
}
@ -514,5 +505,9 @@ sub self2str {
$str.= "]";
}
sub _verbose {
return unless $_verbose;
print STDERR " ## ", @_, "\n";
}
1;

View file

@ -50,7 +50,7 @@ int main(int argc, const char** argv )
OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL)
{
if (retry_open_event--)
Sleep(0); /* yield */
Sleep(100);
else
{
fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n",