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
262a2ab5
Commit
262a2ab5
authored
Mar 13, 2012
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monty's cleanup of my_thr_init.c
and collateral changes
parent
d32b537e
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
130 additions
and
93 deletions
+130
-93
mysql-test/suite/perfschema/r/all_instances.result
mysql-test/suite/perfschema/r/all_instances.result
+2
-0
mysys/my_thr_init.c
mysys/my_thr_init.c
+101
-73
mysys/my_winthread.c
mysys/my_winthread.c
+0
-2
storage/maria/unittest/ma_test_loghandler_multithread-t.c
storage/maria/unittest/ma_test_loghandler_multithread-t.c
+1
-2
storage/perfschema/unittest/pfs-t.cc
storage/perfschema/unittest/pfs-t.cc
+3
-2
storage/perfschema/unittest/pfs_instr-oom-t.cc
storage/perfschema/unittest/pfs_instr-oom-t.cc
+3
-2
storage/perfschema/unittest/pfs_instr-t.cc
storage/perfschema/unittest/pfs_instr-t.cc
+3
-2
storage/perfschema/unittest/pfs_instr_class-oom-t.cc
storage/perfschema/unittest/pfs_instr_class-oom-t.cc
+4
-2
storage/perfschema/unittest/pfs_instr_class-t.cc
storage/perfschema/unittest/pfs_instr_class-t.cc
+4
-2
unittest/mysys/base64-t.c
unittest/mysys/base64-t.c
+3
-2
unittest/mysys/bitmap-t.c
unittest/mysys/bitmap-t.c
+3
-2
unittest/mysys/my_malloc-t.c
unittest/mysys/my_malloc-t.c
+3
-2
No files found.
mysql-test/suite/perfschema/r/all_instances.result
View file @
262a2ab5
...
...
@@ -27,8 +27,10 @@ wait/synch/mutex/mysys/THR_LOCK::mutex
wait/synch/mutex/mysys/THR_LOCK_charset
wait/synch/mutex/mysys/THR_LOCK_heap
wait/synch/mutex/mysys/THR_LOCK_isam
wait/synch/mutex/mysys/THR_LOCK_lock
wait/synch/mutex/mysys/THR_LOCK_malloc
wait/synch/mutex/mysys/THR_LOCK_myisam
wait/synch/mutex/mysys/THR_LOCK_myisam_mmap
wait/synch/mutex/mysys/THR_LOCK_net
wait/synch/mutex/mysys/THR_LOCK_open
wait/synch/mutex/mysys/THR_LOCK_threads
...
...
mysys/my_thr_init.c
View file @
262a2ab5
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2011 Oracle and/or its affiliates.
Copyright 2008-2011 Monty Program 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
...
...
@@ -61,6 +62,77 @@ static uint get_thread_lib(void);
static
my_bool
my_thread_global_init_done
=
0
;
/*
These are mutexes not used by safe_mutex or my_thr_init.c
We want to free these earlier than other mutex so that safe_mutex
can detect if all mutex and memory is freed properly.
*/
static
void
my_thread_init_common_mutex
(
void
)
{
mysql_mutex_init
(
key_THR_LOCK_open
,
&
THR_LOCK_open
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_lock
,
&
THR_LOCK_lock
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_isam
,
&
THR_LOCK_isam
,
MY_MUTEX_INIT_SLOW
);
mysql_mutex_init
(
key_THR_LOCK_myisam
,
&
THR_LOCK_myisam
,
MY_MUTEX_INIT_SLOW
);
mysql_mutex_init
(
key_THR_LOCK_myisam_mmap
,
&
THR_LOCK_myisam_mmap
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_heap
,
&
THR_LOCK_heap
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_net
,
&
THR_LOCK_net
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_charset
,
&
THR_LOCK_charset
,
MY_MUTEX_INIT_FAST
);
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
mysql_mutex_init
(
key_LOCK_localtime_r
,
&
LOCK_localtime_r
,
MY_MUTEX_INIT_SLOW
);
#endif
}
void
my_thread_destroy_common_mutex
(
void
)
{
mysql_mutex_destroy
(
&
THR_LOCK_open
);
mysql_mutex_destroy
(
&
THR_LOCK_lock
);
mysql_mutex_destroy
(
&
THR_LOCK_isam
);
mysql_mutex_destroy
(
&
THR_LOCK_myisam
);
mysql_mutex_destroy
(
&
THR_LOCK_myisam_mmap
);
mysql_mutex_destroy
(
&
THR_LOCK_heap
);
mysql_mutex_destroy
(
&
THR_LOCK_net
);
mysql_mutex_destroy
(
&
THR_LOCK_charset
);
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
mysql_mutex_destroy
(
&
LOCK_localtime_r
);
#endif
}
/*
These mutexes are used by my_thread_init() and after
my_thread_destroy_mutex()
*/
static
void
my_thread_init_internal_mutex
(
void
)
{
mysql_mutex_init
(
key_THR_LOCK_threads
,
&
THR_LOCK_threads
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_malloc
,
&
THR_LOCK_malloc
,
MY_MUTEX_INIT_FAST
);
mysql_cond_init
(
key_THR_COND_threads
,
&
THR_COND_threads
,
NULL
);
}
void
my_thread_destroy_internal_mutex
(
void
)
{
mysql_mutex_destroy
(
&
THR_LOCK_threads
);
mysql_mutex_destroy
(
&
THR_LOCK_malloc
);
mysql_cond_destroy
(
&
THR_COND_threads
);
}
static
void
my_thread_init_thr_mutex
(
struct
st_my_thread_var
*
var
)
{
mysql_mutex_init
(
key_my_thread_var_mutex
,
&
var
->
mutex
,
MY_MUTEX_INIT_FAST
);
mysql_cond_init
(
key_my_thread_var_suspend
,
&
var
->
suspend
,
NULL
);
}
static
void
my_thread_destory_thr_mutex
(
struct
st_my_thread_var
*
var
)
{
mysql_mutex_destroy
(
&
var
->
mutex
);
mysql_cond_destroy
(
&
var
->
suspend
);
}
/**
Re-initialize components initialized early with @c my_thread_global_init.
Some mutexes were initialized before the instrumentation.
...
...
@@ -79,41 +151,17 @@ void my_thread_global_reinit(void)
my_init_mysys_psi_keys
();
#endif
my
sql_mutex_destroy
(
&
THR_LOCK_isam
);
my
sql_mutex_init
(
key_THR_LOCK_isam
,
&
THR_LOCK_isam
,
MY_MUTEX_INIT_SLOW
);
my
_thread_destroy_common_mutex
(
);
my
_thread_init_common_mutex
(
);
mysql_mutex_destroy
(
&
THR_LOCK_heap
);
mysql_mutex_init
(
key_THR_LOCK_heap
,
&
THR_LOCK_heap
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_destroy
(
&
THR_LOCK_net
);
mysql_mutex_init
(
key_THR_LOCK_net
,
&
THR_LOCK_net
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_destroy
(
&
THR_LOCK_myisam
);
mysql_mutex_init
(
key_THR_LOCK_myisam
,
&
THR_LOCK_myisam
,
MY_MUTEX_INIT_SLOW
);
mysql_mutex_destroy
(
&
THR_LOCK_malloc
);
mysql_mutex_init
(
key_THR_LOCK_malloc
,
&
THR_LOCK_malloc
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_destroy
(
&
THR_LOCK_open
);
mysql_mutex_init
(
key_THR_LOCK_open
,
&
THR_LOCK_open
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_destroy
(
&
THR_LOCK_charset
);
mysql_mutex_init
(
key_THR_LOCK_charset
,
&
THR_LOCK_charset
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_destroy
(
&
THR_LOCK_threads
);
mysql_mutex_init
(
key_THR_LOCK_threads
,
&
THR_LOCK_threads
,
MY_MUTEX_INIT_FAST
);
mysql_cond_destroy
(
&
THR_COND_threads
);
mysql_cond_init
(
key_THR_COND_threads
,
&
THR_COND_threads
,
NULL
);
my_thread_destroy_internal_mutex
();
my_thread_init_internal_mutex
();
tmp
=
my_pthread_getspecific
(
struct
st_my_thread_var
*
,
THR_KEY_mysys
);
DBUG_ASSERT
(
tmp
);
mysql_mutex_destroy
(
&
tmp
->
mutex
);
mysql_mutex_init
(
key_my_thread_var_mutex
,
&
tmp
->
mutex
,
MY_MUTEX_INIT_FAST
);
mysql_cond_destroy
(
&
tmp
->
suspend
);
mysql_cond_init
(
key_my_thread_var_suspend
,
&
tmp
->
suspend
,
NULL
);
my_thread_destory_thr_mutex
(
tmp
);
my_thread_init_thr_mutex
(
tmp
);
}
/*
...
...
@@ -131,6 +179,8 @@ my_bool my_thread_global_init(void)
{
int
pth_ret
;
/* Normally this should never be called twice */
DBUG_ASSERT
(
my_thread_global_init_done
==
0
);
if
(
my_thread_global_init_done
)
return
0
;
my_thread_global_init_done
=
1
;
...
...
@@ -141,10 +191,8 @@ my_bool my_thread_global_init(void)
return
1
;
}
mysql_mutex_init
(
key_THR_LOCK_malloc
,
&
THR_LOCK_malloc
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_open
,
&
THR_LOCK_open
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_charset
,
&
THR_LOCK_charset
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_threads
,
&
THR_LOCK_threads
,
MY_MUTEX_INIT_FAST
);
/* Mutex used by my_thread_init() and after my_thread_destroy_mutex() */
my_thread_init_internal_mutex
();
if
(
my_thread_init
())
return
1
;
...
...
@@ -178,26 +226,16 @@ my_bool my_thread_global_init(void)
}
#endif
/* TARGET_OS_LINUX */
mysql_mutex_init
(
key_THR_LOCK_lock
,
&
THR_LOCK_lock
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_isam
,
&
THR_LOCK_isam
,
MY_MUTEX_INIT_SLOW
);
mysql_mutex_init
(
key_THR_LOCK_myisam
,
&
THR_LOCK_myisam
,
MY_MUTEX_INIT_SLOW
);
mysql_mutex_init
(
key_THR_LOCK_myisam_mmap
,
&
THR_LOCK_myisam_mmap
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_heap
,
&
THR_LOCK_heap
,
MY_MUTEX_INIT_FAST
);
mysql_mutex_init
(
key_THR_LOCK_net
,
&
THR_LOCK_net
,
MY_MUTEX_INIT_FAST
);
mysql_cond_init
(
key_THR_COND_threads
,
&
THR_COND_threads
,
NULL
);
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
mysql_mutex_init
(
key_LOCK_localtime_r
,
&
LOCK_localtime_r
,
MY_MUTEX_INIT_SLOW
);
#endif
#ifdef _MSC_VER
install_sigabrt_handler
();
#endif
my_thread_init_common_mutex
();
return
0
;
}
/**
End the mysys thread system. Called when ending the last thread
*/
void
my_thread_global_end
(
void
)
{
struct
timespec
abstime
;
...
...
@@ -228,24 +266,17 @@ void my_thread_global_end(void)
}
mysql_mutex_unlock
(
&
THR_LOCK_threads
);
mysql_mutex_destroy
(
&
THR_LOCK_malloc
);
mysql_mutex_destroy
(
&
THR_LOCK_open
);
mysql_mutex_destroy
(
&
THR_LOCK_lock
);
mysql_mutex_destroy
(
&
THR_LOCK_isam
);
mysql_mutex_destroy
(
&
THR_LOCK_myisam
);
mysql_mutex_destroy
(
&
THR_LOCK_myisam_mmap
);
mysql_mutex_destroy
(
&
THR_LOCK_heap
);
mysql_mutex_destroy
(
&
THR_LOCK_net
);
mysql_mutex_destroy
(
&
THR_LOCK_charset
);
my_thread_destroy_common_mutex
();
/*
Only destroy the mutex & conditions if we don't have other threads around
that could use them.
*/
if
(
all_threads_killed
)
{
mysql_mutex_destroy
(
&
THR_LOCK_thread
s
);
my
sql_cond_destroy
(
&
THR_COND_threads
);
pthread_key_delete
(
THR_KEY_mysy
s
);
my
_thread_destroy_internal_mutex
(
);
}
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
mysql_mutex_destroy
(
&
LOCK_localtime_r
);
#endif
pthread_key_delete
(
THR_KEY_mysys
);
my_thread_global_init_done
=
0
;
}
...
...
@@ -277,8 +308,7 @@ my_bool my_thread_init(void)
my_bool
error
=
0
;
#ifdef EXTRA_DEBUG_THREADS
fprintf
(
stderr
,
"my_thread_init(): pthread_self: 0x%lx
\n
"
,
(
ulong
)
pthread_self
());
fprintf
(
stderr
,
"my_thread_init(): pthread_self: %p
\n
"
,
pthread_self
());
#endif
if
(
my_pthread_getspecific
(
struct
st_my_thread_var
*
,
THR_KEY_mysys
))
...
...
@@ -301,8 +331,7 @@ my_bool my_thread_init(void)
}
pthread_setspecific
(
THR_KEY_mysys
,
tmp
);
tmp
->
pthread_self
=
pthread_self
();
mysql_mutex_init
(
key_my_thread_var_mutex
,
&
tmp
->
mutex
,
MY_MUTEX_INIT_FAST
);
mysql_cond_init
(
key_my_thread_var_suspend
,
&
tmp
->
suspend
,
NULL
);
my_thread_init_thr_mutex
(
tmp
);
tmp
->
stack_ends_here
=
(
char
*
)
&
tmp
+
STACK_DIRECTION
*
(
long
)
my_thread_stack_size
;
...
...
@@ -340,8 +369,8 @@ void my_thread_end(void)
tmp
=
my_pthread_getspecific
(
struct
st_my_thread_var
*
,
THR_KEY_mysys
);
#ifdef EXTRA_DEBUG_THREADS
fprintf
(
stderr
,
"my_thread_end(): tmp:
0x%lx pthread_self: 0x%lx
thread_id: %ld
\n
"
,
(
long
)
tmp
,
(
long
)
pthread_self
(),
tmp
?
(
long
)
tmp
->
id
:
0L
);
fprintf
(
stderr
,
"my_thread_end(): tmp:
%p pthread_self: %p
thread_id: %ld
\n
"
,
tmp
,
pthread_self
(),
tmp
?
(
long
)
tmp
->
id
:
0L
);
#endif
#ifdef HAVE_PSI_INTERFACE
...
...
@@ -368,8 +397,7 @@ void my_thread_end(void)
tmp
->
dbug
=
0
;
}
#endif
mysql_cond_destroy
(
&
tmp
->
suspend
);
mysql_mutex_destroy
(
&
tmp
->
mutex
);
my_thread_destory_thr_mutex
(
tmp
);
/*
Decrement counter for number of running threads. We are using this
...
...
mysys/my_winthread.c
View file @
262a2ab5
...
...
@@ -24,8 +24,6 @@
#include <process.h>
#include <signal.h>
static
void
install_sigabrt_handler
(
void
);
struct
thread_start_parameter
{
pthread_handler
func
;
...
...
storage/maria/unittest/ma_test_loghandler_multithread-t.c
View file @
262a2ab5
...
...
@@ -336,8 +336,6 @@ int main(int argc __attribute__((unused)),
thr_setconcurrency
(
2
);
#endif
my_thread_global_init
();
if
(
ma_control_file_open
(
TRUE
,
TRUE
))
{
fprintf
(
stderr
,
"Can't init control file (%d)
\n
"
,
errno
);
...
...
@@ -551,6 +549,7 @@ int main(int argc __attribute__((unused)),
if
(
maria_log_remove
(
maria_data_root
))
exit
(
1
);
my_end
(
0
);
return
(
exit_status
());
}
...
...
storage/perfschema/unittest/pfs-t.cc
View file @
262a2ab5
...
...
@@ -1214,11 +1214,12 @@ void do_all_tests()
test_file_instrumentation_leak
();
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
plan
(
153
);
MY_INIT
(
"pfs-t"
);
MY_INIT
(
argv
[
0
]
);
do_all_tests
();
my_end
(
0
);
return
0
;
}
storage/perfschema/unittest/pfs_instr-oom-t.cc
View file @
262a2ab5
...
...
@@ -206,11 +206,12 @@ void do_all_tests()
PFS_atomic
::
cleanup
();
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
plan
(
8
);
MY_INIT
(
"pfs_instr-oom-t"
);
MY_INIT
(
argv
[
0
]
);
do_all_tests
();
my_end
(
0
);
return
0
;
}
storage/perfschema/unittest/pfs_instr-t.cc
View file @
262a2ab5
...
...
@@ -410,11 +410,12 @@ void do_all_tests()
PFS_atomic
::
cleanup
();
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
plan
(
102
);
MY_INIT
(
"pfs_instr-t"
);
MY_INIT
(
argv
[
0
]
);
do_all_tests
();
my_end
(
0
);
return
0
;
}
storage/perfschema/unittest/pfs_instr_class-oom-t.cc
View file @
262a2ab5
...
...
@@ -54,11 +54,13 @@ void do_all_tests()
PFS_atomic
::
cleanup
();
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
plan
(
6
);
MY_INIT
(
"pfs_instr_info-oom-t"
);
MY_INIT
(
argv
[
0
]
);
do_all_tests
();
my_end
(
0
);
return
0
;
}
storage/perfschema/unittest/pfs_instr_class-t.cc
View file @
262a2ab5
...
...
@@ -568,11 +568,13 @@ void do_all_tests()
PFS_atomic
::
cleanup
();
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
plan
(
196
);
MY_INIT
(
"pfs_instr_info-t"
);
MY_INIT
(
argv
[
0
]
);
do_all_tests
();
my_end
(
0
);
return
0
;
}
unittest/mysys/base64-t.c
View file @
262a2ab5
...
...
@@ -24,11 +24,11 @@
#define BASE64_ROWS 4
/* Number of ok(..) */
int
main
(
void
)
main
(
int
argc
,
char
*
argv
[]
)
{
int
i
,
cmp
;
size_t
j
,
k
,
l
,
dst_len
,
needed_length
;
MY_INIT
(
"base64-t"
);
MY_INIT
(
argv
[
0
]
);
plan
(
BASE64_LOOP_COUNT
*
BASE64_ROWS
);
...
...
@@ -92,5 +92,6 @@ main(void)
(
uint
)
src_len
,
(
uint
)
dst_len
);
}
}
my_end
(
0
);
return
exit_status
();
}
unittest/mysys/bitmap-t.c
View file @
262a2ab5
...
...
@@ -519,12 +519,12 @@ my_bool do_test(uint bitsize)
return
TRUE
;
}
int
main
()
int
main
(
int
argc
,
char
*
argv
[]
)
{
int
i
;
int
const
min_size
=
1
;
int
const
max_size
=
MAX_TESTED_BITMAP_SIZE
;
MY_INIT
(
"bitmap-t"
);
MY_INIT
(
argv
[
0
]
);
plan
((
max_size
-
min_size
)
/
7
+
1
);
...
...
@@ -535,5 +535,6 @@ int main()
*/
for
(
i
=
min_size
;
i
<
max_size
;
i
+=
7
)
ok
(
do_test
(
i
)
==
0
,
"bitmap size %d"
,
i
);
my_end
(
0
);
return
exit_status
();
}
unittest/mysys/my_malloc-t.c
View file @
262a2ab5
...
...
@@ -17,10 +17,10 @@
#include <my_sys.h>
#include "tap.h"
int
main
(
void
)
int
main
(
int
argc
,
char
*
argv
[]
)
{
void
*
p
;
MY_INIT
(
"my_malloc-t"
);
MY_INIT
(
argv
[
0
]
);
plan
(
4
);
...
...
@@ -38,6 +38,7 @@ int main(void)
ok
((
my_free
(
p
),
1
),
"Free NULL pointer."
);
my_end
(
0
);
return
exit_status
();
}
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