diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-01-29 01:50:24 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-07-13 12:10:23 +0200 |
commit | 503eba23c9a199583eddee9e169a4fddbecf416f (patch) | |
tree | 3f164baad45efd799a6ed0559dfb5278ef96c692 /vcl/headless | |
parent | 917be98e3f277960635ac66bcea510c2454c80d6 (diff) |
SVP correctly handle sleep time
Don't add 500 usec for 0ms sleeps and always round up the sleep
time so we won't sleep too short.
Change-Id: I28dda435de44031c050b6edbfae1e9d392465d24
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpinst.cxx | 12 |
1 files changed, 8 insertions, 4 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 |