summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2001-05-07 22:15:29 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2001-05-07 22:15:29 (GMT)
commit1fd84bd466e07b5c88b1f036312f10d05e028c4c (patch)
treeca17d3333e1dbe2e2e189da350fd409b5ad2c2f7
parent0582de1567897a26acf73bb3d9982b9d622f445e (diff)
downloadtcl-1fd84bd466e07b5c88b1f036312f10d05e028c4c.zip
tcl-1fd84bd466e07b5c88b1f036312f10d05e028c4c.tar.gz
tcl-1fd84bd466e07b5c88b1f036312f10d05e028c4c.tar.bz2
rand() gets != seeds in != threads [Bug 416643]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclExecute.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ec5700..691b34b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-05-07 Miguel Sofer <msofer@users.sourceforge.net>
+
+ * generic/tclExecute.c: insure different rand() seeds in different
+ threads [Bug 416643]
+
2001-05-03 Jeff Hobbs <jeffh@ActiveState.com>
* tests/tcltest.test: removed extraneous 'c' (doh!) [Bug: 414031]
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index fcad4a5..1e9f1e6 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.21 2001/04/07 03:15:38 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.22 2001/05/07 22:15:29 msofer Exp $
*/
#include "tclInt.h"
@@ -4083,7 +4083,13 @@ ExprRandFunc(interp, eePtr, clientData)
if (!(iPtr->flags & RAND_SEED_INITIALIZED)) {
iPtr->flags |= RAND_SEED_INITIALIZED;
- iPtr->randSeed = TclpGetClicks();
+
+ /*
+ * Take into consideration the thread this interp is running in order
+ * to insure different seeds in different threads (bug #416643)
+ */
+
+ iPtr->randSeed = TclpGetClicks() + ((long) Tcl_GetCurrentThread() << 12);
/*
* Make sure 1 <= randSeed <= (2^31) - 2. See below.