Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ce9f585b
Commit
ce9f585b
authored
Oct 08, 2008
by
Magnus Svensson
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
efb93f8a
911e6386
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
151 additions
and
63 deletions
+151
-63
Makefile.am
Makefile.am
+4
-0
mysql-test/lib/My/CoreDump.pm
mysql-test/lib/My/CoreDump.pm
+5
-3
mysql-test/lib/My/File/Path.pm
mysql-test/lib/My/File/Path.pm
+24
-17
mysql-test/lib/My/Handles.pm
mysql-test/lib/My/Handles.pm
+69
-0
mysql-test/lib/My/Platform.pm
mysql-test/lib/My/Platform.pm
+1
-1
mysql-test/lib/My/SafeProcess.pm
mysql-test/lib/My/SafeProcess.pm
+31
-15
mysql-test/lib/My/SafeProcess/Base.pm
mysql-test/lib/My/SafeProcess/Base.pm
+2
-26
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
+14
-1
mysql-test/mysql-test-run.pl
mysql-test/mysql-test-run.pl
+1
-0
No files found.
Makefile.am
View file @
ce9f585b
...
@@ -121,6 +121,10 @@ test-reprepare:
...
@@ -121,6 +121,10 @@ test-reprepare:
test
:
test-unit test-ns test-pr
test
:
test-unit test-ns test-pr
smoke
:
cd
mysql-test
;
\
@PERL@ ./mysql-test-run.pl
--do-test
=
s
test-full
:
test test-nr test-ps
test-full
:
test test-nr test-ps
test-force
:
test-force
:
...
...
mysql-test/lib/My/CoreDump.pm
View file @
ce9f585b
...
@@ -25,6 +25,8 @@ use File::Temp qw/ tempfile tempdir /;
...
@@ -25,6 +25,8 @@ use File::Temp qw/ tempfile tempdir /;
sub
_gdb
{
sub
_gdb
{
my
(
$core_name
)
=
@_
;
my
(
$core_name
)
=
@_
;
print
"
\n
Trying 'gdb' to get a backtrace
\n
";
return
unless
-
f
$core_name
;
return
unless
-
f
$core_name
;
my
$dir
=
tempdir
(
CLEANUP
=>
1
);
my
$dir
=
tempdir
(
CLEANUP
=>
1
);
...
@@ -35,7 +37,7 @@ sub _gdb {
...
@@ -35,7 +37,7 @@ sub _gdb {
"
quit
\n
";
"
quit
\n
";
# Find out name of binary that generated core
# Find out name of binary that generated core
my
$list
=
`
gdb -c
$core_name
-x
$tmp_name
-
q --
batch 2>&1
`
my
$list
=
`
gdb -c
$core_name
-x
$tmp_name
-batch 2>&1
`
or
return
;
or
return
;
my
$binary
;
my
$binary
;
...
@@ -47,9 +49,9 @@ sub _gdb {
...
@@ -47,9 +49,9 @@ sub _gdb {
return
unless
$binary
;
return
unless
$binary
;
print
"
G
enerated by '
$binary
'
\n
";
print
"
- core g
enerated by '
$binary
'
\n
";
my
$list
=
`
gdb
$binary
-c
$core_name
-x
$tmp_name
-
q --
batch 2>&1
`
my
$list
=
`
gdb
$binary
-c
$core_name
-x
$tmp_name
-batch 2>&1
`
or
return
;
or
return
;
print
$list
,
"
\n
";
print
$list
,
"
\n
";
...
...
mysql-test/lib/My/File/Path.pm
View file @
ce9f585b
...
@@ -20,33 +20,40 @@ use Exporter;
...
@@ -20,33 +20,40 @@ use Exporter;
use
base
"
Exporter
";
use
base
"
Exporter
";
our
@EXPORT
=
qw /
rmtree
mkpath
copytree
/
;
our
@EXPORT
=
qw /
rmtree
mkpath
copytree
/
;
use
File::
Find
;
use
File::
Find
;
use
File::
Path
;
use
File::
Copy
;
use
File::
Copy
;
use
Carp
;
use
Carp
;
use
My::
Handles
;
no
warnings
'
redefine
';
sub
rmtree
{
sub
rmtree
{
my
(
$dir
)
=
@_
;
my
(
$dir
)
=
@_
;
#
# chmod all files to 0777 before calling rmtree
#
find
(
{
find
(
{
no_chdir
=>
1
,
bydepth
=>
1
,
no_chdir
=>
1
,
wanted
=>
sub
{
wanted
=>
sub
{
chmod
(
0777
,
$_
)
my
$name
=
$_
;
or
warn
("
couldn't chmod(0777,
$_
): $!
");
if
(
!-
l
$name
&&
-
d
_
){
}
return
if
(
rmdir
(
$name
)
==
1
);
},
$dir
chmod
(
0777
,
$name
)
or
carp
("
couldn't chmod(0777,
$name
): $!
");
);
return
if
(
rmdir
(
$name
)
==
1
);
# Call rmtree from File::Path
# Failed to remove the directory, analyze
goto
&
File::Path::
rmtree
;
carp
("
Couldn't remove directory '
$name
': $!
");
My::Handles::
show_handles
(
$name
);
}
else
{
return
if
(
unlink
(
$name
)
==
1
);
chmod
(
0777
,
$name
)
or
carp
("
couldn't chmod(0777,
$name
): $!
");
return
if
(
unlink
(
$name
)
==
1
);
carp
("
Couldn't delete file '
$name
': $!
");
My::Handles::
show_handles
(
$name
);
}
}
},
$dir
);
};
};
...
...
mysql-test/lib/My/Handles.pm
0 → 100755
View file @
ce9f585b
# -*- cperl -*-
# Copyright (C) 2008 MySQL AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package
My::
Handles
;
use
strict
;
use
Carp
;
use
My::
Platform
;
my
$handle_exe
;
if
(
IS_WINDOWS
){
# Check if handle.exe is available
# Pass switch to accept the EULA to avoid hanging
# if the program hasn't been run before.
my
$list
=
`
handle.exe -? -accepteula 2>&1
`;
foreach
my
$line
(
split
('
\
n
',
$list
))
{
$handle_exe
=
"
$1.$2
"
if
(
$line
=~
/Handle v([0-9]*)\.([0-9]*)/
);
}
if
(
$handle_exe
){
print
"
Found handle.exe version
$handle_exe
\n
";
}
}
sub
show_handles
{
my
(
$dir
)
=
@_
;
return
unless
$handle_exe
;
return
unless
$dir
;
$dir
=
native_path
(
$dir
);
# Get a list of open handles in a particular directory
my
$list
=
`
handle.exe "
$dir
" 2>&1
`
or
return
;
foreach
my
$line
(
split
('
\
n
',
$list
))
{
return
if
(
$line
=~
/No matching handles found/
);
}
print
"
\n
";
print
"
=
"
x
50
,
"
\n
";
print
"
Open handles in '
$dir
':
\n
";
print
"
$list
\n
";
print
"
=
"
x
50
,
"
\n\n
";
return
;
}
1
;
mysql-test/lib/My/Platform.pm
View file @
ce9f585b
...
@@ -18,7 +18,7 @@ package My::Platform;
...
@@ -18,7 +18,7 @@ package My::Platform;
use
strict
;
use
strict
;
use
File::
Basename
;
use
File::
Basename
;
use
My::
File::
Path
;
# Patched version of File::Path
use
File::
Path
;
# Patched version of File::Path
use
base
qw(Exporter)
;
use
base
qw(Exporter)
;
our
@EXPORT
=
qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
our
@EXPORT
=
qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
...
...
mysql-test/lib/My/SafeProcess.pm
View file @
ce9f585b
...
@@ -66,7 +66,9 @@ END {
...
@@ -66,7 +66,9 @@ END {
for
my
$proc
(
values
%
running
){
for
my
$proc
(
values
%
running
){
if
(
$proc
->
is_child
(
$$
)
){
if
(
$proc
->
is_child
(
$$
)
){
#print "Killing: $proc\n";
#print "Killing: $proc\n";
$proc
->
kill
();
if
(
$proc
->
wait_one
(
0
)){
$proc
->
kill
();
}
}
}
}
}
}
}
...
@@ -146,7 +148,7 @@ sub new {
...
@@ -146,7 +148,7 @@ sub new {
print
"
### safe_path:
",
$safe_path
,
"
",
join
("
",
@safe_args
),
"
\n
"
print
"
### safe_path:
",
$safe_path
,
"
",
join
("
",
@safe_args
),
"
\n
"
if
$verbose
>
1
;
if
$verbose
>
1
;
my
(
$pid
,
$winpid
)
=
create_process
(
my
$pid
=
create_process
(
path
=>
$safe_path
,
path
=>
$safe_path
,
input
=>
$input
,
input
=>
$input
,
output
=>
$output
,
output
=>
$output
,
...
@@ -159,7 +161,7 @@ sub new {
...
@@ -159,7 +161,7 @@ sub new {
my
$proc
=
bless
my
$proc
=
bless
({
({
SAFE_PID
=>
$pid
,
SAFE_PID
=>
$pid
,
SAFE_WINPID
=>
$
winpid
,
SAFE_WINPID
=>
$
pid
,
# Inidicates this is always a real process
SAFE_NAME
=>
$name
,
SAFE_NAME
=>
$name
,
SAFE_SHUTDOWN
=>
$shutdown
,
SAFE_SHUTDOWN
=>
$shutdown
,
PARENT
=>
$$
,
PARENT
=>
$$
,
...
@@ -302,6 +304,18 @@ sub shutdown {
...
@@ -302,6 +304,18 @@ sub shutdown {
}
}
sub
_winpid
($)
{
my
(
$pid
)
=
@_
;
# In win32 perl, the pid is already the winpid
return
$pid
unless
IS_CYGWIN
;
# In cygwin, the pid is the pseudo process ->
# get the real winpid of my_safe_process
return
Cygwin::
pid_to_winpid
(
$pid
);
}
#
#
# Tell the process to die as fast as possible
# Tell the process to die as fast as possible
#
#
...
@@ -311,22 +325,24 @@ sub start_kill {
...
@@ -311,22 +325,24 @@ sub start_kill {
_verbose
("
start_kill:
$self
");
_verbose
("
start_kill:
$self
");
my
$ret
=
1
;
my
$ret
=
1
;
my
$pid
;
my
$pid
=
$self
->
{
SAFE_PID
};
die
"
INTERNAL ERROR: no pid
"
unless
defined
$pid
;
if
(
IS_WINDOWS
and
defined
$self
->
{
SAFE_WINPID
})
if
(
IS_WINDOWS
and
defined
$self
->
{
SAFE_WINPID
})
{
{
die
"
INTERNAL ERROR: no safe_kill
"
unless
defined
$safe_kill
;
die
"
INTERNAL ERROR: no safe_kill
"
unless
defined
$safe_kill
;
die
"
INTERNAL ERROR: no winpid
"
unless
defined
$self
->
{
SAFE_WINPID
};
# Use my_safe_kill to tell my_safe_process
my
$winpid
=
_winpid
(
$pid
);
# it's time to kill it's child and return
$ret
=
system
(
$safe_kill
,
$winpid
)
>>
8
;
$pid
=
$self
->
{
SAFE_WINPID
};
$ret
=
system
(
$safe_kill
,
$pid
)
>>
8
;
if
(
$ret
==
3
){
if
(
IS_CYGWIN
and
$ret
==
3
)
print
"
Couldn't open the winpid:
$winpid
",
{
"
for pid:
$pid
, try one more time
\n
";
print
"
safe_process is gone, kickstart the fake process
\n
";
sleep
(
1
);
if
(
kill
(
15
,
$self
->
{
SAFE_PID
})
!=
1
){
$winpid
=
_winpid
(
$pid
);
print
STDERR
"
Failed to kickstart the fake process
\n
";
$ret
=
system
(
$safe_kill
,
$winpid
)
>>
8
;
}
print
"
Couldn't open the winpid:
$winpid
",
"
for pid:
$pid
, continue and see what happens...
\n
";
}
}
}
}
else
else
...
...
mysql-test/lib/My/SafeProcess/Base.pm
View file @
ce9f585b
...
@@ -33,30 +33,6 @@ use base qw(Exporter);
...
@@ -33,30 +33,6 @@ use base qw(Exporter);
our
@EXPORT
=
qw(create_process)
;
our
@EXPORT
=
qw(create_process)
;
sub
winpid
{
my
(
$pid
)
=
@_
;
return
undef
unless
$^O
eq
"
cygwin
";
# The child get a new winpid when the exec takes
# place, wait for that to happen
my
$winpid
;
my
$delay
=
0
;
do
{
# Yield to the child
select
(
undef
,
undef
,
undef
,
$delay
);
# Increase the delay slightly for each loop
$delay
+=
0.000001
;
$winpid
=
Cygwin::
pid_to_winpid
(
$pid
);
}
until
(
$winpid
!=
$pid
);
return
$winpid
;
}
#
#
# safe_fork
# safe_fork
...
@@ -179,7 +155,7 @@ sub create_process {
...
@@ -179,7 +155,7 @@ sub create_process {
or
croak
("
unable to reestablish STDIN
");
or
croak
("
unable to reestablish STDIN
");
#printf STDERR "stdin %d, stdout %d, stderr %d\n",
#printf STDERR "stdin %d, stdout %d, stderr %d\n",
# fileno STDIN, fileno STDOUT, fileno STDERR;
# fileno STDIN, fileno STDOUT, fileno STDERR;
return
wantarray
?
(
$pid
,
$pid
)
:
$pid
;
return
$pid
;
}
}
...
@@ -190,7 +166,7 @@ sub create_process {
...
@@ -190,7 +166,7 @@ sub create_process {
# Parent
# Parent
$pipe
->
reader
();
$pipe
->
reader
();
my
$line
=
<
$pipe
>
;
# Wait for child to say it's ready
my
$line
=
<
$pipe
>
;
# Wait for child to say it's ready
return
wantarray
?
(
$pid
,
winpid
(
$pid
))
:
$pid
;
return
$pid
;
}
}
$SIG
{
INT
}
=
'
DEFAULT
';
$SIG
{
INT
}
=
'
DEFAULT
';
...
...
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
View file @
ce9f585b
...
@@ -49,12 +49,25 @@ int main(int argc, const char** argv )
...
@@ -49,12 +49,25 @@ int main(int argc, const char** argv )
while
((
shutdown_event
=
while
((
shutdown_event
=
OpenEvent
(
EVENT_MODIFY_STATE
,
FALSE
,
safe_process_name
))
==
NULL
)
OpenEvent
(
EVENT_MODIFY_STATE
,
FALSE
,
safe_process_name
))
==
NULL
)
{
{
/*
Check if the process is alive, otherwise there is really
no idea to retry the open of the event
*/
HANDLE
process
;
if
((
process
=
OpenProcess
(
SYNCHRONIZE
,
FALSE
,
pid
))
==
NULL
)
{
fprintf
(
stderr
,
"Could not open event or process %d, error: %d
\n
"
,
pid
,
GetLastError
());
exit
(
3
);
}
CloseHandle
(
process
);
if
(
retry_open_event
--
)
if
(
retry_open_event
--
)
Sleep
(
100
);
Sleep
(
100
);
else
else
{
{
fprintf
(
stderr
,
"Failed to open shutdown_event '%s', error: %d
\n
"
,
fprintf
(
stderr
,
"Failed to open shutdown_event '%s', error: %d
\n
"
,
safe_process_name
,
GetLastError
());
safe_process_name
,
GetLastError
());
exit
(
3
);
exit
(
3
);
}
}
}
}
...
...
mysql-test/mysql-test-run.pl
View file @
ce9f585b
...
@@ -4244,6 +4244,7 @@ sub start_check_testcase ($$$) {
...
@@ -4244,6 +4244,7 @@ sub start_check_testcase ($$$) {
error
=>
$errfile
,
error
=>
$errfile
,
args
=>
\
$args
,
args
=>
\
$args
,
user_data
=>
$errfile
,
user_data
=>
$errfile
,
verbose
=>
$opt_verbose
,
);
);
mtr_report
("
Started
$proc
");
mtr_report
("
Started
$proc
");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment