summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2003-02-01 19:48:22 (GMT)
committerKevin B Kenny <kennykb@acm.org>2003-02-01 19:48:22 (GMT)
commitb6d2ba95de66b5c89d10d8861df1b8d02ec7dcc2 (patch)
tree0b45b8ab91562620a255d76f95bbd7ce80fc33af /generic/tclClock.c
parent8ca7da652a892daee3f4847a3003b6c2abb621d0 (diff)
downloadtcl-b6d2ba95de66b5c89d10d8861df1b8d02ec7dcc2.zip
tcl-b6d2ba95de66b5c89d10d8861df1b8d02ec7dcc2.tar.gz
tcl-b6d2ba95de66b5c89d10d8861df1b8d02ec7dcc2.tar.bz2
2003-02-01 Kevin Kenny <kennykb@users.sourceforge.net>
* doc/Tcl.n: Added headings to the eleven paragraphs, to improve formatting in the tools that attempt to extract tables of contents from the manual pages. [Bug 627455] * generic/tclClock.c: Expanded mutex protection around the setting of env(TZ) and the thread-unsafe call to tzset(). [Bug 656660]
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 2d09974..e98eba6 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclClock.c,v 1.18 2003/01/14 17:51:16 hobbs Exp $
+ * RCS: @(#) $Id: tclClock.c,v 1.19 2003/02/01 19:48:23 kennykb Exp $
*/
#include "tcl.h"
@@ -293,9 +293,12 @@ FormatClock(interp, clockVal, useGMT, format)
/*
* This is a kludge for systems not having the timezone string in
* struct tm. No matter what was specified, they use the local
- * timezone string.
+ * timezone string. Since this kludge requires fiddling with the
+ * TZ environment variable, it will mess up if done on multiple
+ * threads at once. Protect it with a the clock mutex.
*/
+ Tcl_MutexLock( &clockMutex );
if (useGMT) {
CONST char *varValue;
@@ -332,10 +335,16 @@ FormatClock(interp, clockVal, useGMT, format)
Tcl_DStringInit(&buffer);
Tcl_DStringSetLength(&buffer, bufSize);
+ /* If we haven't locked the clock mutex up above, lock it now. */
+
+#if defined(HAVE_TM_ZONE) || defined(WIN32)
Tcl_MutexLock(&clockMutex);
+#endif
result = TclpStrftime(buffer.string, (unsigned int) bufSize,
Tcl_DStringValue(&uniBuffer), timeDataPtr, useGMT);
+#if defined(HAVE_TM_ZONE) || defined(WIN32)
Tcl_MutexUnlock(&clockMutex);
+#endif
Tcl_DStringFree(&uniBuffer);
#if !defined(HAVE_TM_ZONE) && !defined(WIN32)
@@ -349,6 +358,7 @@ FormatClock(interp, clockVal, useGMT, format)
timezone = savedTimeZone;
tzset();
}
+ Tcl_MutexUnlock( &clockMutex );
#endif
if (result == 0) {