mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-09 01:04:44 +08:00
Merge 2.1 r364 (has lots of test fixes).
This commit is contained in:
@@ -42,6 +42,10 @@ sub new {
|
||||
my $self = {
|
||||
task => $task,
|
||||
};
|
||||
open $self->{stdout_copy}, ">&=", *STDOUT
|
||||
or die "Cannot dup stdout: $OS_ERROR";
|
||||
open $self->{stderr_copy}, ">&=", *STDERR
|
||||
or die "Cannot dup stderr: $OS_ERROR";
|
||||
PTDEBUG && _d('Created cleanup task', $task);
|
||||
return bless $self, $class;
|
||||
}
|
||||
@@ -51,6 +55,12 @@ sub DESTROY {
|
||||
my $task = $self->{task};
|
||||
if ( ref $task ) {
|
||||
PTDEBUG && _d('Calling cleanup task', $task);
|
||||
# Temporarily restore STDOUT and STDERR to what they were
|
||||
# when the object was created
|
||||
open local(*STDOUT), ">&=", $self->{stdout_copy}
|
||||
if $self->{stdout_copy};
|
||||
open local(*STDERR), ">&=", $self->{stderr_copy}
|
||||
if $self->{stderr_copy};
|
||||
$task->();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -148,8 +148,9 @@ sub get_duplicate_keys {
|
||||
# Remove clustered duplicates.
|
||||
my $clustered_key = $args{clustered_key} ? $keys{$args{clustered_key}}
|
||||
: undef;
|
||||
PTDEBUG && _d('clustered key:', $clustered_key->{name},
|
||||
$clustered_key->{colnames});
|
||||
PTDEBUG && _d('clustered key:',
|
||||
$clustered_key ? ($clustered_key->{name}, $clustered_key->{colnames})
|
||||
: 'none');
|
||||
if ( $clustered_key
|
||||
&& $args{clustered}
|
||||
&& $args{tbl_info}->{engine}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# This program is copyright 2010-2011 Percona Inc.
|
||||
# This program is copyright 2010-2012 Percona Inc.
|
||||
# Feedback and improvements are welcome.
|
||||
#
|
||||
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
@@ -66,14 +66,12 @@ my %modes = (
|
||||
);
|
||||
|
||||
# This primarily comes from the Perl Cookbook, recipe 15.8
|
||||
|
||||
{
|
||||
|
||||
my $fd_stdin = fileno(STDIN);
|
||||
my $flags;
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
$flags = fcntl(STDIN, F_GETFL, 0)
|
||||
or warn "can't fcntl F_GETFL: $!";
|
||||
or warn "Error getting STDIN flags with fcntl: $OS_ERROR";
|
||||
}
|
||||
my $term = POSIX::Termios->new();
|
||||
$term->getattr($fd_stdin);
|
||||
@@ -105,14 +103,13 @@ my %modes = (
|
||||
$term->setlflag($oterm);
|
||||
$term->setcc( VTIME, 0 );
|
||||
$term->setattr( $fd_stdin, TCSANOW );
|
||||
unless ( $PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
fcntl(STDIN, F_SETFL, $flags)
|
||||
or warn "can't fcntl F_SETFL: $!";
|
||||
if ( !$PerconaTest::DONT_RESTORE_STDIN ) {
|
||||
fcntl(STDIN, F_SETFL, int($flags))
|
||||
or warn "Error restoring STDIN flags with fcntl: $OS_ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
END { cooked() }
|
||||
|
||||
}
|
||||
|
||||
sub readkey {
|
||||
@@ -121,17 +118,16 @@ sub readkey {
|
||||
sysread(STDIN, $key, 1);
|
||||
my $timeout = 0.1;
|
||||
if ( $key eq "\033" ) {
|
||||
# Ugly and broken hack, but good enough for the two minutes it took to write.
|
||||
# Namely, Ctrl escapes, the F-NUM keys, and other stuff you can send from the keyboard
|
||||
# take more than one "character" to represent, and would be wrong to break into pieces.
|
||||
{
|
||||
my $x = '';
|
||||
STDIN->blocking(0);
|
||||
sysread(STDIN, $x, 2);
|
||||
STDIN->blocking(1);
|
||||
$key .= $x;
|
||||
redo if $key =~ /\[[0-2](?:[0-9];)?$/
|
||||
}
|
||||
# Ugly and broken hack, but good enough for the two minutes it took
|
||||
# to write. Namely, Ctrl escapes, the F-NUM keys, and other stuff
|
||||
# you can send from the keyboard take more than one "character" to
|
||||
# represent, and would be wrong to break into pieces.
|
||||
my $x = '';
|
||||
STDIN->blocking(0);
|
||||
sysread(STDIN, $x, 2);
|
||||
STDIN->blocking(1);
|
||||
$key .= $x;
|
||||
redo if $key =~ /\[[0-2](?:[0-9];)?$/
|
||||
}
|
||||
cooked();
|
||||
return $key;
|
||||
|
||||
@@ -218,7 +218,7 @@ collect() {
|
||||
fi
|
||||
fi
|
||||
|
||||
(echo $ts; df -h) >> "$d/$p-df" &
|
||||
(echo $ts; df -k) >> "$d/$p-df" &
|
||||
|
||||
(echo $ts; netstat -antp) >> "$d/$p-netstat" &
|
||||
(echo $ts; netstat -s) >> "$d/$p-netstat_s" &
|
||||
|
||||
Reference in New Issue
Block a user