summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/networkselftest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/other/networkselftest')
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 7ce385121c..7ef830d89f 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -171,14 +171,16 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout
{
QElapsedTimer timer;
timer.start();
+ int t = timeout;
forever {
if (socket->bytesAvailable() >= minBytesAvailable)
return true;
- timeout = qt_subtract_from_timeout(timeout, timer.elapsed());
- if (socket->state() == QAbstractSocket::UnconnectedState
- || timeout == 0)
+ if (socket->state() == QAbstractSocket::UnconnectedState)
return false;
- if (!socket->waitForReadyRead(timeout))
+ if (!socket->waitForReadyRead(t))
+ return false;
+ t = qt_subtract_from_timeout(timeout, timer.elapsed());
+ if (t == 0)
return false;
}
}
@@ -199,6 +201,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000)
#endif
QTime timer;
timer.start();
+ int t = timeout;
forever {
if (socket->bytesToWrite() == 0
#ifndef QT_NO_SSL
@@ -206,11 +209,12 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000)
#endif
)
return true;
- timeout = qt_subtract_from_timeout(timeout, timer.elapsed());
- if (socket->state() == QAbstractSocket::UnconnectedState
- || timeout == 0)
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ return false;
+ if (!socket->waitForBytesWritten(t))
return false;
- if (!socket->waitForBytesWritten(timeout))
+ t = qt_subtract_from_timeout(timeout, timer.elapsed());
+ if (t == 0)
return false;
}
}