diff options
| author | hobbs <hobbs> | 2001-03-29 19:29:22 (GMT) | 
|---|---|---|
| committer | hobbs <hobbs> | 2001-03-29 19:29:22 (GMT) | 
| commit | 12d17b17c1747afbeb1f905126a863dd697f3007 (patch) | |
| tree | 494bb584735025c34e4a86e1801577b6a260abf6 /unix/tclUnixThrd.c | |
| parent | f70d6355fd7474ae83bd61502ec11f763d19a899 (diff) | |
| download | tcl-12d17b17c1747afbeb1f905126a863dd697f3007.zip tcl-12d17b17c1747afbeb1f905126a863dd697f3007.tar.gz tcl-12d17b17c1747afbeb1f905126a863dd697f3007.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.c | 13 | 
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);      }  }  | 
