From 1fd84bd466e07b5c88b1f036312f10d05e028c4c Mon Sep 17 00:00:00 2001
From: Miguel Sofer <miguel.sofer@gmail.com>
Date: Mon, 7 May 2001 22:15:29 +0000
Subject: rand() gets != seeds in != threads [Bug 416643]

---
 ChangeLog            |  5 +++++
 generic/tclExecute.c | 10 ++++++++--
 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.
-- 
cgit v0.12