summaryrefslogtreecommitdiff
path: root/mysql-test/lib/mtr_process.pl
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/lib/mtr_process.pl')
-rw-r--r--mysql-test/lib/mtr_process.pl116
1 files changed, 56 insertions, 60 deletions
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 868b6d4f1ec..9d0c1f601ba 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -4,12 +4,10 @@
# and is part of the translation of the Bourne shell script with the
# same name.
-#use Carp qw(cluck);
use Socket;
use Errno;
use strict;
-#use POSIX ":sys_wait_h";
use POSIX 'WNOHANG';
sub mtr_run ($$$$$$;$);
@@ -93,8 +91,6 @@ sub spawn_impl ($$$$$$$$) {
my $pid_file= shift; # FIXME
my $spawn_opts= shift;
- mtr_error("Can't spawn with empty \"path\"") unless defined $path;
-
if ( $::opt_script_debug )
{
print STDERR "\n";
@@ -118,6 +114,9 @@ sub spawn_impl ($$$$$$$$) {
print STDERR "#### ", "-" x 78, "\n";
}
+ mtr_error("Can't spawn with empty \"path\"") unless defined $path;
+
+
FORK:
{
my $pid= fork();
@@ -339,19 +338,6 @@ sub mtr_kill_leftovers () {
mtr_report("Killing Possible Leftover Processes");
mtr_debug("mtr_kill_leftovers(): started.");
- mkpath("$::opt_vardir/log"); # Needed for mysqladmin log
-
- # Stop or kill Instance Manager and all its children. If we failed to do
- # that, we can only abort -- there is nothing left to do.
-
- mtr_error("Failed to stop Instance Manager.")
- unless mtr_im_stop($::instance_manager);
-
- # Start shutdown of masters and slaves. Don't touch IM-managed mysqld
- # instances -- they should be stopped by mtr_im_stop().
-
- mtr_debug("Shutting down mysqld-instances...");
-
my @kill_pids;
my %admin_pids;
@@ -377,40 +363,41 @@ sub mtr_kill_leftovers () {
$srv->{'pid'}= 0; # Assume we are done with it
}
- # Start shutdown of clusters.
-
- mtr_debug("Shutting down cluster...");
-
- foreach my $cluster (@{$::clusters})
+ if ( ! $::opt_skip_ndbcluster )
{
- mtr_debug(" - cluster " .
- "(pid: $cluster->{pid}; " .
- "pid file: '$cluster->{path_pid})");
-
- my $pid= mtr_ndbmgm_start($cluster, "shutdown");
-
- # Save the pid of the ndb_mgm process
- $admin_pids{$pid}= 1;
-
- push(@kill_pids,{
- pid => $cluster->{'pid'},
- pidfile => $cluster->{'path_pid'}
- });
+ # Start shutdown of clusters.
+ mtr_debug("Shutting down cluster...");
- $cluster->{'pid'}= 0; # Assume we are done with it
+ foreach my $cluster (@{$::clusters})
+ {
+ mtr_debug(" - cluster " .
+ "(pid: $cluster->{pid}; " .
+ "pid file: '$cluster->{path_pid})");
+ my $pid= mtr_ndbmgm_start($cluster, "shutdown");
- foreach my $ndbd (@{$cluster->{'ndbds'}})
- {
- mtr_debug(" - ndbd " .
- "(pid: $ndbd->{pid}; " .
- "pid file: '$ndbd->{path_pid})");
+ # Save the pid of the ndb_mgm process
+ $admin_pids{$pid}= 1;
push(@kill_pids,{
- pid => $ndbd->{'pid'},
- pidfile => $ndbd->{'path_pid'},
+ pid => $cluster->{'pid'},
+ pidfile => $cluster->{'path_pid'}
});
- $ndbd->{'pid'}= 0; # Assume we are done with it
+
+ $cluster->{'pid'}= 0; # Assume we are done with it
+
+ foreach my $ndbd (@{$cluster->{'ndbds'}})
+ {
+ mtr_debug(" - ndbd " .
+ "(pid: $ndbd->{pid}; " .
+ "pid file: '$ndbd->{path_pid})");
+
+ push(@kill_pids,{
+ pid => $ndbd->{'pid'},
+ pidfile => $ndbd->{'path_pid'},
+ });
+ $ndbd->{'pid'}= 0; # Assume we are done with it
+ }
}
}
@@ -451,25 +438,35 @@ sub mtr_kill_leftovers () {
while ( my $elem= readdir(RUNDIR) )
{
- my $pidfile= "$rundir/$elem";
-
- if ( -f $pidfile )
+ # Only read pid from files that end with .pid
+ if ( $elem =~ /.*[.]pid$/)
{
- mtr_debug("Processing PID file: '$pidfile'...");
+ my $pidfile= "$rundir/$elem";
- my $pid= mtr_get_pid_from_file($pidfile);
+ if ( -f $pidfile )
+ {
+ mtr_debug("Processing PID file: '$pidfile'...");
- mtr_debug("Got pid: $pid from file '$pidfile'");
+ my $pid= mtr_get_pid_from_file($pidfile);
- if ( $::glob_cygwin_perl or kill(0, $pid) )
- {
- mtr_debug("There is process with pid $pid -- scheduling for kill.");
- push(@pids, $pid); # We know (cygwin guess) it exists
- }
- else
- {
- mtr_debug("There is no process with pid $pid -- skipping.");
- }
+ mtr_debug("Got pid: $pid from file '$pidfile'");
+
+ if ( $::glob_cygwin_perl or kill(0, $pid) )
+ {
+ mtr_debug("There is process with pid $pid -- scheduling for kill.");
+ push(@pids, $pid); # We know (cygwin guess) it exists
+ }
+ else
+ {
+ mtr_debug("There is no process with pid $pid -- skipping.");
+ }
+ }
+ }
+ else
+ {
+ mtr_warning("Found non pid file $elem in $rundir")
+ if -f "$rundir/$elem";
+ next;
}
}
closedir(RUNDIR);
@@ -1100,7 +1097,6 @@ sub mtr_kill_processes ($) {
sub mtr_exit ($) {
my $code= shift;
-# cluck("Called mtr_exit()");
mtr_timer_stop_all($::glob_timers);
local $SIG{HUP} = 'IGNORE';
# ToDo: Signalling -$$ will only work if we are the process group