From 96d75f8cee167761e320fd1158cbf30ae96ab7cc Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 23 Mar 2006 17:36:51 +0000 Subject: [PATCH] fix timeout value passed to pthread_cond_timedwait --- stepmania/src/arch/Threads/Threads_Pthreads.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/stepmania/src/arch/Threads/Threads_Pthreads.cpp b/stepmania/src/arch/Threads/Threads_Pthreads.cpp index 3a247fc385..8ef0d32a4e 100644 --- a/stepmania/src/arch/Threads/Threads_Pthreads.cpp +++ b/stepmania/src/arch/Threads/Threads_Pthreads.cpp @@ -229,9 +229,21 @@ bool EventImpl_Pthreads::Wait( RageTimer *pTimeout ) return true; } + float fSecondsInFuture = -pTimeout->Ago(); + + RageTimer timeofday; + { + timeval tv; + gettimeofday( &tv, NULL ); + timeofday.m_secs = tv.tv_sec; + timeofday.m_us = tv.tv_usec; + } + timeofday += fSecondsInFuture; + + timespec abstime; - abstime.tv_sec = pTimeout->m_secs; - abstime.tv_nsec = pTimeout->m_us * 1000; + abstime.tv_sec = timeofday.m_secs; + abstime.tv_nsec = timeofday.m_us * 1000; int iRet = pthread_cond_timedwait( &m_Cond, &m_pParent->mutex, &abstime ); return iRet != ETIMEDOUT;