diff options
author | nick@mysql.com <> | 2002-10-24 14:33:24 -0600 |
---|---|---|
committer | nick@mysql.com <> | 2002-10-24 14:33:24 -0600 |
commit | eba70d6c8035108633b74b072648f10d442884e0 (patch) | |
tree | a4e8accbfad564c2b676948f926f7502fc2dfda4 | |
parent | 96c56eacf3cd46be0d02e1a019e311f8ab13fb82 (diff) | |
download | mariadb-git-eba70d6c8035108633b74b072648f10d442884e0.tar.gz |
Moved rand initialization from mysqld.cc to sql_class.cc:THD::THD()
-rw-r--r-- | sql/mysqld.cc | 11 | ||||
-rw-r--r-- | sql/sql_class.cc | 14 |
2 files changed, 15 insertions, 10 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e6c2c198722..e91ede0bf71 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -290,7 +290,7 @@ int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice */ static bool kill_in_progress=FALSE; -static struct rand_struct sql_rand; +struct rand_struct sql_rand; // used by sql_class.cc:THD::THD() static int cleanup_done; static char **defaults_argv; char glob_hostname[FN_REFLEN]; @@ -2416,15 +2416,6 @@ static void create_new_thread(THD *thd) for (uint i=0; i < 8 ; i++) // Generate password teststring thd->scramble[i]= (char) (rnd(&sql_rand)*94+33); thd->scramble[8]=0; - /* - We need good random number initialization for new thread - Just coping global one will not work - */ - { - ulong tmp=(ulong) (rnd(&sql_rand) * 3000000); - randominit(&(thd->rand), tmp + (ulong) start_time, - tmp + (ulong) thread_id); - } thd->real_id=pthread_self(); // Keep purify happy /* Start a new thread to handle connection */ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 59c28797a43..e9ea61f4f1f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -37,6 +37,8 @@ #include <mysys_err.h> #include <assert.h> +extern struct rand_struct sql_rand; + /***************************************************************************** ** Instansiate templates *****************************************************************************/ @@ -172,6 +174,18 @@ THD::THD():user_time(0), fatal_error(0), transaction.trans_log.end_of_file= max_binlog_cache_size; } #endif + + /* + We need good random number initialization for new thread + Just coping global one will not work + */ + { + pthread_mutex_lock(&LOCK_thread_count); + ulong tmp=(ulong) (rnd(&sql_rand) * 3000000); + randominit(&rand, tmp + (ulong) start_time, + tmp + (ulong) thread_id); + pthread_mutex_unlock(&LOCK_thread_count); + } } /* Do operations that may take a long time */ |