summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/synch/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'winpr/libwinpr/synch/timer.c')
-rw-r--r--winpr/libwinpr/synch/timer.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/winpr/libwinpr/synch/timer.c b/winpr/libwinpr/synch/timer.c
index 8238a88..354382c 100644
--- a/winpr/libwinpr/synch/timer.c
+++ b/winpr/libwinpr/synch/timer.c
@@ -707,11 +707,11 @@ static void timespec_add_ms(struct timespec* tspec, UINT32 ms)
static void timespec_gettimeofday(struct timespec* tspec)
{
- struct timeval tval;
WINPR_ASSERT(tspec);
- gettimeofday(&tval, NULL);
- tspec->tv_sec = tval.tv_sec;
- tspec->tv_nsec = tval.tv_usec * 1000;
+
+ const UINT64 ns = winpr_GetUnixTimeNS();
+ tspec->tv_sec = WINPR_TIME_NS_TO_S(ns);
+ tspec->tv_nsec = WINPR_TIME_NS_REM_NS(ns);
}
static INT64 timespec_compare(const struct timespec* tspec1, const struct timespec* tspec2)
@@ -881,12 +881,13 @@ static void* TimerQueueThread(void* arg)
status = pthread_cond_timedwait(&(timerQueue->cond), &(timerQueue->cond_mutex), &timeout);
FireExpiredTimerQueueTimers(timerQueue);
+ const BOOL bCancelled = timerQueue->bCancelled;
pthread_mutex_unlock(&(timerQueue->cond_mutex));
if ((status != ETIMEDOUT) && (status != 0))
break;
- if (timerQueue->bCancelled)
+ if (bCancelled)
break;
}