summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp53
1 files changed, 6 insertions, 47 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index b130a9b..6eafe05 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -42,6 +42,7 @@
//#define QNATIVESOCKETENGINE_DEBUG
#include "qnativesocketengine_p.h"
+#include "private/qcore_unix_p.h"
#include "qiodevice.h"
#include "qhostaddress.h"
#include "qvarlengtharray.h"
@@ -833,33 +834,11 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
- QTime timer;
- timer.start();
-
int retval;
- do {
- if (selectForRead)
- retval = select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
- else
- retval = select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
-
- if (retval != -1 || errno != EINTR)
- break;
-
- if (timeout > 0) {
- // recalculate the timeout
- int t = timeout - timer.elapsed();
- if (t < 0) {
- // oops, timeout turned negative?
- retval = -1;
- break;
- }
-
- tv.tv_sec = t / 1000;
- tv.tv_usec = (t % 1000) * 1000;
- }
- } while (true);
-
+ if (selectForRead)
+ retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
+ else
+ retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
return retval;
}
@@ -880,28 +859,8 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
- QTime timer;
- timer.start();
-
int ret;
- do {
- ret = select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
- if (ret != -1 || errno != EINTR)
- break;
-
- if (timeout > 0) {
- // recalculate the timeout
- int t = timeout - timer.elapsed();
- if (t < 0) {
- // oops, timeout turned negative?
- ret = -1;
- break;
- }
-
- tv.tv_sec = t / 1000;
- tv.tv_usec = (t % 1000) * 1000;
- }
- } while (true);
+ ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
if (ret <= 0)
return ret;