Commit 00d47646 authored by nick@mysql.com's avatar nick@mysql.com

Moved rand initialization from mysqld.cc to sql_class.cc:THD::THD()

parent 562b1718
...@@ -288,7 +288,7 @@ int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice ...@@ -288,7 +288,7 @@ int segfaulted = 0; // ensure we do not enter SIGSEGV handler twice
*/ */
static bool kill_in_progress=FALSE; 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 int cleanup_done;
static char **defaults_argv; static char **defaults_argv;
char glob_hostname[FN_REFLEN]; char glob_hostname[FN_REFLEN];
...@@ -2423,15 +2423,7 @@ static void create_new_thread(THD *thd) ...@@ -2423,15 +2423,7 @@ static void create_new_thread(THD *thd)
for (uint i=0; i < 8 ; i++) // Generate password teststring for (uint i=0; i < 8 ; i++) // Generate password teststring
thd->scramble[i]= (char) (rnd(&sql_rand)*94+33); thd->scramble[i]= (char) (rnd(&sql_rand)*94+33);
thd->scramble[8]=0; 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 thd->real_id=pthread_self(); // Keep purify happy
/* Start a new thread to handle connection */ /* Start a new thread to handle connection */
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <mysys_err.h> #include <mysys_err.h>
#include <assert.h> #include <assert.h>
extern struct rand_struct sql_rand;
/***************************************************************************** /*****************************************************************************
** Instansiate templates ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
...@@ -158,6 +160,18 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -158,6 +160,18 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
transaction.trans_log.end_of_file= max_binlog_cache_size; transaction.trans_log.end_of_file= max_binlog_cache_size;
} }
#endif #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 */ /* Do operations that may take a long time */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment