diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-06-08 19:05:24 -0300 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-06-08 19:05:24 -0300 |
commit | 01912b20bc5e1d9bc3ec80289b0de71f9797eaa9 (patch) | |
tree | 97b468751d966e832b7bffe2727bb965d99961d5 /sql/sql_connect.cc | |
parent | a7c2707740054204e52f4665c4d81159272d40b7 (diff) | |
download | mariadb-git-01912b20bc5e1d9bc3ec80289b0de71f9797eaa9.tar.gz |
Fix for a valgrind warning due to use of a uninitialized
variable. The problem was that THD::connect_utime could be
used without being initialized when the main thread is used
to handle connections (--thread-handling=no-threads).
sql/mysqld.cc:
Set THD::start_utime even in no-threads handling mode.
sql/sql_class.cc:
Initialize variable.
sql/sql_class.h:
Rename connect_utime to prior_thr_create_utime as to
better reflect it's use intention.
sql/sql_connect.cc:
Check only if a thread was actually created.
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r-- | sql/sql_connect.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index e4d7cf6feb5..98574a07a4e 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1074,8 +1074,8 @@ static void prepare_new_connection_state(THD* thd) pthread_handler_t handle_one_connection(void *arg) { THD *thd= (THD*) arg; - ulong launch_time= (ulong) ((thd->thr_create_utime= my_micro_time()) - - thd->connect_utime); + + thd->thr_create_utime= my_micro_time(); if (thread_scheduler.init_new_connection_thread()) { @@ -1084,8 +1084,20 @@ pthread_handler_t handle_one_connection(void *arg) thread_scheduler.end_thread(thd,0); return 0; } - if (launch_time >= slow_launch_time*1000000L) - statistic_increment(slow_launch_threads,&LOCK_status); + + /* + If a thread was created to handle this connection: + increment slow_launch_threads counter if it took more than + slow_launch_time seconds to create the thread. + */ + if (thd->prior_thr_create_utime) + { + ulong launch_time= (ulong) (thd->thr_create_utime - + thd->prior_thr_create_utime); + if (launch_time >= slow_launch_time*1000000L) + statistic_increment(slow_launch_threads, &LOCK_status); + thd->prior_thr_create_utime= 0; + } /* handle_one_connection() is normally the only way a thread would |