diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-07-10 16:52:39 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-12 11:46:39 (GMT) |
commit | 4afde6f85050cc3e9267947999dc55918b1bd36c (patch) | |
tree | a196b0a6e31967417c3a9235a5c50dd5f74f9978 /src/corelib/kernel | |
parent | eeeea5ad7acb4006ad4f2f556665eba848279ecf (diff) | |
download | Qt-4afde6f85050cc3e9267947999dc55918b1bd36c.zip Qt-4afde6f85050cc3e9267947999dc55918b1bd36c.tar.gz Qt-4afde6f85050cc3e9267947999dc55918b1bd36c.tar.bz2 |
Accept defeat when select(2)ing without a monotonic clock
We prefer to use the monotonic clock because it's never affected by time
jumps (such as the user changing the date, or the system adjusting for
any other reasons, including automatic leap seconds). But if a system
doesn't have a monotonic clock, we simply accept the regular, real time
clock and hope it doesn't jump.
This is better than the current code that never restarts a call. The
side-effect is that a 30-second select may become a 3630-second select
if someone sets the clock back one hour.
Task-number: QTBUG-22301
Change-Id: Ia5a3bb453cd475f45b03637e2549165589fd2524
(cherry-picked from qtbase commit c64d602df3712c0d147b7b689d29f79c700e63bc)
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcore_unix.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index cc54798..8b1c2a3 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -63,12 +63,8 @@ QT_BEGIN_NAMESPACE static inline bool time_update(struct timeval *tv, const struct timeval &start, const struct timeval &timeout) { - if (!QElapsedTimer::isMonotonic()) { - // we cannot recalculate the timeout without a monotonic clock as the time may have changed - return false; - } - - // clock source is monotonic, so we can recalculate how much timeout is left + // clock source is (hopefully) monotonic, so we can recalculate how much timeout is left; + // if it isn't monotonic, we'll simply hope that it hasn't jumped, because we have no alternative struct timeval now = qt_gettime(); *tv = timeout + start - now; return tv->tv_sec >= 0; |