diff options
author | unknown <msvensson@shellback.> | 2006-12-14 15:23:44 +0100 |
---|---|---|
committer | unknown <msvensson@shellback.> | 2006-12-14 15:23:44 +0100 |
commit | 29bcffd77e32abc94600b9078f254b159a2dde8d (patch) | |
tree | f23da2855e569b61111327134ef1ba91ff7ff353 /mysys | |
parent | a63a66cb46d16088fd9c634c2b0ebca0471e78ad (diff) | |
download | mariadb-git-29bcffd77e32abc94600b9078f254b159a2dde8d.tar.gz |
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
include/config-win.h:
Move all defines for 'pthread_cond_timedwait' to my_pthread.h
include/my_global.h:
Move all defines for 'pthread_cond_timedwait' to my_pthread.h
include/my_pthread.h:
Redefine "struct timespec" to better suite the needs
of 'pthread_cond_timedwait' for windows implementation
Add windows specific define for set_timespec_nsec
Move all defines related to pthread_cond_timed wait to same file
Declare union for reading FILETIME as __int64 with correct alignment
mysys/my_wincond.c:
Use 'GetSystemTimeAsFileTime()' both for getting start and current time
Use new members of "struct timespec"
Make sure the calculated timeout value never exceeds the value
passed to set_timespec/set_timespec_nsec
server-tools/instance-manager/guardian.cc:
Use set_timespec macro
server-tools/instance-manager/instance.cc:
Use set_timespec macro
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_wincond.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 8c497e8f250..327addff2cc 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -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); |