diff options
-rw-r--r-- | vcl/headless/svpinst.cxx | 12 | ||||
-rw-r--r-- | vcl/inc/unx/salunxtime.h | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 2e803decccd3..5140b27340b3 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -360,10 +360,14 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong timeval Timeout; // determine remaining timeout. gettimeofday (&Timeout, nullptr); - nTimeoutMS = (m_aTimeout.tv_sec - Timeout.tv_sec) * 1000 - + m_aTimeout.tv_usec/1000 - Timeout.tv_usec/1000; - if( nTimeoutMS < 0 ) - nTimeoutMS = 0; + if ( m_aTimeout > Timeout ) + { + int nTimeoutMicroS = m_aTimeout.tv_usec - Timeout.tv_usec; + nTimeoutMS = (m_aTimeout.tv_sec - Timeout.tv_sec) * 1000 + + nTimeoutMicroS / 1000; + if ( nTimeoutMicroS % 1000 ) + nTimeoutMS += 1; + } } else nTimeoutMS = -1; // wait until something happens diff --git a/vcl/inc/unx/salunxtime.h b/vcl/inc/unx/salunxtime.h index e9b4b81af7f6..1ed979e83e5b 100644 --- a/vcl/inc/unx/salunxtime.h +++ b/vcl/inc/unx/salunxtime.h @@ -59,7 +59,7 @@ inline timeval &operator -= ( timeval &t1, const timeval &t2 ) inline timeval &operator += ( timeval &t1, sal_uIntPtr t2 ) { t1.tv_sec += t2 / 1000; - t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500; + t1.tv_usec += (t2 % 1000) * 1000; if( t1.tv_usec > 1000000 ) { t1.tv_sec++; |