summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-03-29 19:29:22 (GMT)
committerhobbs <hobbs>2001-03-29 19:29:22 (GMT)
commita8176e9b8e9a21ba42f9d4e1937e035a5e4bfe26 (patch)
tree494bb584735025c34e4a86e1801577b6a260abf6 /unix/tclUnixThrd.c
parent072c84c4a0576326d3d5766634f2e6a0823bf112 (diff)
downloadtcl-a8176e9b8e9a21ba42f9d4e1937e035a5e4bfe26.zip
tcl-a8176e9b8e9a21ba42f9d4e1937e035a5e4bfe26.tar.gz
tcl-a8176e9b8e9a21ba42f9d4e1937e035a5e4bfe26.tar.bz2
* unix/tclUnixThrd.c (Tcl_ConditionWait): fixed handling of
timeout for threads (corrects excessive CPU usage issue for Tk on Unix in threaded Tcl environment). (ruppert) [Bug #411603]
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index bbbb3f2..faf08ed 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -681,8 +681,17 @@ Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
if (timePtr == NULL) {
pthread_cond_wait(pcondPtr, pmutexPtr);
} else {
- ptime.tv_sec = timePtr->sec + TclpGetSeconds();
- ptime.tv_nsec = 1000 * timePtr->usec;
+ Tcl_Time now;
+
+ /*
+ * Make sure to take into account the microsecond component of the
+ * current time, including possible overflow situations. [Bug #411603]
+ */
+
+ TclpGetTime(&now);
+ ptime.tv_sec = timePtr->sec + now.sec +
+ (timePtr->usec + now.usec) / 1000000;
+ ptime.tv_nsec = 1000 * ((timePtr->usec + now.usec) % 1000000);
pthread_cond_timedwait(pcondPtr, pmutexPtr, &ptime);
}
}