summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-02-18 12:35:44 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-02-18 12:35:44 (GMT)
commit185b0d14932f4cc8503e6dd235da5bd90ebc777c (patch)
tree9182e5085918a168d44eed5e3c4e4efb70fa456d /generic/tclClock.c
parent8844e2789a8e8d854f53069ea852ec5ef726757c (diff)
parent345894cae91f9e72bbbfd6264ab98a2263d9dd1b (diff)
downloadtcl-185b0d14932f4cc8503e6dd235da5bd90ebc777c.zip
tcl-185b0d14932f4cc8503e6dd235da5bd90ebc777c.tar.gz
tcl-185b0d14932f4cc8503e6dd235da5bd90ebc777c.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index eb52244..7863f84 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -2024,10 +2024,27 @@ ClockSecondsObjCmd(
static void
TzsetIfNecessary(void)
{
- static char* tzWas = (char *)INT2PTR(-1); /* Previous value of TZ, protected by
+ static char *tzWas = (char *)INT2PTR(-1); /* Previous value of TZ, protected by
* clockMutex. */
+ static long tzLastRefresh = 0; /* Used for latency before next refresh */
+ static size_t tzEnvEpoch = 0; /* Last env epoch, for faster signaling,
+ that TZ changed via TCL */
const char *tzIsNow; /* Current value of TZ */
+ /*
+ * Prevent performance regression on some platforms by resolving of system time zone:
+ * small latency for check whether environment was changed (once per second)
+ * no latency if environment was changed with tcl-env (compare both epoch values)
+ */
+ Tcl_Time now;
+ Tcl_GetTime(&now);
+ if (now.sec == tzLastRefresh && tzEnvEpoch == TclEnvEpoch) {
+ return;
+ }
+
+ tzEnvEpoch = TclEnvEpoch;
+ tzLastRefresh = now.sec;
+
Tcl_MutexLock(&clockMutex);
tzIsNow = getenv("TZ");
if (tzIsNow != NULL && (tzWas == NULL || tzWas == INT2PTR(-1)