diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-10 16:14:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-28 07:13:23 +0100 |
commit | bf5f2a9e3e3bf70c373b65bf95a332f4e1c514f9 (patch) | |
tree | ae2925a69f3f69854d7d0c30d2e51eee9dec321f /src/network/socket/qnativesocketengine_unix.cpp | |
parent | 5c5c9c26d299cd230dc48efcaaf3627861efa673 (diff) |
Switch to struct timespec everywhere instead of timeval
This avoids an extra division by 1000 when getting the current time.
This can't overflow, under normal circumstances, even on 32-bit: when
adding two values less than 1 billion, the result is less than 2
billion, which is less than 2^31.
Change-Id: I6f8e1aadfe2fcf6ac8da584eab4c1e61aee51cbb
Reviewed-by: David Faure (KDE) <faure@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 4f3408b067..4c94c4dbb9 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -1126,9 +1126,9 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co FD_ZERO(&fds); FD_SET(socketDescriptor, &fds); - struct timeval tv; + struct timespec tv; tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; + tv.tv_nsec = (timeout % 1000) * 1000 * 1000; int retval; if (selectForRead) @@ -1152,9 +1152,9 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c if (checkWrite) FD_SET(socketDescriptor, &fdwrite); - struct timeval tv; + struct timespec tv; tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; + tv.tv_nsec = (timeout % 1000) * 1000 * 1000; int ret; ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv); |