summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-12-11 14:19:30 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-12-11 14:28:41 (GMT)
commit9aa60dfdf5b4837b9ceb15d8fcbc96f37dce7b5a (patch)
tree28abb71b4b696c485198e618abd0dca49dab536b /src/corelib
parent05ba6bad6c0927d22ccf026446dfdb9d85b3f03e (diff)
downloadQt-9aa60dfdf5b4837b9ceb15d8fcbc96f37dce7b5a.zip
Qt-9aa60dfdf5b4837b9ceb15d8fcbc96f37dce7b5a.tar.gz
Qt-9aa60dfdf5b4837b9ceb15d8fcbc96f37dce7b5a.tar.bz2
Check if the timeout expired during the time update in qt_safe_select
It can happen that select(2) returns -1 with EINTR, but the time remaining was too small for us to update the time. Our own processing (plus the syscall to clock_gettime(2)) leads us past the timeout, so we get a negative timeval. Task-number: QTBUG-6755 Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qcore_unix.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 5885591..d0dc7be 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -129,7 +129,7 @@ static inline bool time_update(struct timeval *tv, const struct timeval &start,
// clock source is monotonic, so we can recalculate how much timeout is left
struct timeval now = qt_gettime();
*tv = timeout + start - now;
- return true;
+ return tv->tv_sec >= 0;
}
int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
@@ -154,7 +154,8 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
// recalculate the timeout
if (!time_update(&timeout, start, *orig_timeout)) {
- // clock reset, fake timeout error
+ // timeout during update
+ // or clock reset, fake timeout error
return 0;
}
}