summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/networkselftest/tst_networkselftest.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-01-26 11:27:37 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-01-26 11:27:37 +0000
commit0a1af55a9b69f7fd58dbce43a0d4c1faf0143838 (patch)
tree26da168e740734d168be37803abec2f8739b213d /tests/auto/other/networkselftest/tst_networkselftest.cpp
parentb8fb0ee999d32401157be8d86e5a03185aadbb9e (diff)
parent158a3a4159bdc5a49caecd63e021dacbc06cf23c (diff)
Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/other/networkselftest/tst_networkselftest.cpp')
-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 4a7c4db9b3..0ce0e8d0f5 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -166,14 +166,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;
}
}
@@ -194,6 +196,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
@@ -201,11 +204,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;
}
}