summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authornick@mysql.com <>2002-10-29 12:28:14 -0700
committernick@mysql.com <>2002-10-29 12:28:14 -0700
commite10d3ed1290f4b1645c674406bb86bf1c8c9989d (patch)
tree0326b69f2fdd9aeca86deb8b05d6b832fdfbee11 /sql
parent60e1175e0ca924c0352f0e1dd727c2ccc9ee47b3 (diff)
downloadmariadb-git-e10d3ed1290f4b1645c674406bb86bf1c8c9989d.tar.gz
moved RAND initialization from mysqld.cc to sql_class.cc:THD::THD()
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc12
-rw-r--r--sql/sql_class.cc14
2 files changed, 16 insertions, 10 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index b5c789548e7..01053ba0f28 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -249,7 +249,7 @@ extern int init_master_info(MASTER_INFO* mi);
// and are treated as aliases for each other
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,time_zone[30];
static const char *default_table_type_name;
@@ -2257,15 +2257,7 @@ 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 ace7c291ed3..eada94e3d40 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -35,6 +35,8 @@
#include <io.h>
#endif
+extern struct rand_struct sql_rand;
+
/*****************************************************************************
** Instansiate templates
*****************************************************************************/
@@ -147,6 +149,18 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(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 */