mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
BUG#24687 func_misc test fails on win64
- Use same precision (milliseconds) for all time functions used when calculating time for pthread_cond_timedwait - Use 'GetSystemTimeAsFileTime' for both start and curr time
This commit is contained in:
parent
fdbc84d27c
commit
c41e307d85
6 changed files with 96 additions and 58 deletions
|
|
@ -54,14 +54,30 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|||
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
struct timespec *abstime)
|
||||
{
|
||||
struct _timeb curtime;
|
||||
int result;
|
||||
long timeout;
|
||||
_ftime(&curtime);
|
||||
timeout= ((long) (abstime->tv_sec - curtime.time)*1000L +
|
||||
(long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L);
|
||||
if (timeout < 0) /* Some safety */
|
||||
long timeout;
|
||||
union ft64 now;
|
||||
|
||||
GetSystemTimeAsFileTime(&now.ft);
|
||||
|
||||
/*
|
||||
- subtract start time from current time(values are in 100ns units
|
||||
- convert to millisec by dividing with 10000
|
||||
- subtract time since start from max timeout
|
||||
*/
|
||||
timeout= abstime->timeout_msec - (long)((now.i64 - abstime->start.i64) / 10000);
|
||||
|
||||
/* Don't allow the timeout to be negative */
|
||||
if (timeout < 0)
|
||||
timeout = 0L;
|
||||
|
||||
/*
|
||||
Make sure the calucated time does not exceed original timeout
|
||||
value which could cause "wait for ever" if system time changes
|
||||
*/
|
||||
if (timeout > abstime->timeout_msec)
|
||||
timeout= abstime->timeout_msec;
|
||||
|
||||
InterlockedIncrement(&cond->waiting);
|
||||
LeaveCriticalSection(mutex);
|
||||
result=WaitForSingleObject(cond->semaphore,timeout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue