summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/socket/qlocalserver_unix.cpp22
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp2
2 files changed, 7 insertions, 17 deletions
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index 5ffe0c0..e09e547 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -216,24 +216,14 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut)
timeout.tv_sec = msec / 1000;
timeout.tv_usec = (msec % 1000) * 1000;
- // timeout can not be 0 or else select will return an error.
- if (0 == msec)
- timeout.tv_usec = 1000;
-
int result = -1;
- // on Linux timeout will be updated by select, but _not_ on other systems.
- QTime timer;
- timer.start();
- while (pendingConnections.isEmpty() && (-1 == msec || timer.elapsed() < msec)) {
- result = ::select(listenSocket + 1, &readfds, 0, 0, &timeout);
- if (-1 == result && errno != EINTR) {
- setError(QLatin1String("QLocalServer::waitForNewConnection"));
- closeServer();
- break;
- }
- if (result > 0)
- _q_onNewConnection();
+ result = qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout);
+ if (-1 == result) {
+ setError(QLatin1String("QLocalServer::waitForNewConnection"));
+ closeServer();
}
+ if (result > 0)
+ _q_onNewConnection();
if (timedOut)
*timedOut = (result == 0);
}
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index be39d00..ab7b0ac 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -976,7 +976,7 @@ void tst_QLocalSocket::writeOnlySocket()
#if defined(Q_OS_SYMBIAN)
QTest::qWait(250);
#endif
- QVERIFY(server.waitForNewConnection());
+ QVERIFY(server.waitForNewConnection(200));
QLocalSocket* serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);