summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qhttpsocketengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qhttpsocketengine.cpp')
-rw-r--r--src/network/socket/qhttpsocketengine.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index b929ee088e..7b601db79d 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -36,6 +36,7 @@
#include "qhostaddress.h"
#include "qurl.h"
#include "private/qhttpnetworkreply_p.h"
+#include "private/qiodevice_p.h"
#include "qelapsedtimer.h"
#include "qnetworkinterface.h"
@@ -330,19 +331,6 @@ bool QHttpSocketEngine::setOption(SocketOption option, int value)
return false;
}
-/*
- Returns the difference between msecs and elapsed. If msecs is -1,
- however, -1 is returned.
-*/
-static int qt_timeout_value(int msecs, int elapsed)
-{
- if (msecs == -1)
- return -1;
-
- int timeout = msecs - elapsed;
- return timeout < 0 ? 0 : timeout;
-}
-
bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
{
Q_D(const QHttpSocketEngine);
@@ -355,7 +343,7 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
// Wait for more data if nothing is available.
if (!d->socket->bytesAvailable()) {
- if (!d->socket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) {
+ if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
if (d->socket->state() == QAbstractSocket::UnconnectedState)
return true;
setError(d->socket->error(), d->socket->errorString());
@@ -367,7 +355,7 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
// If we're not connected yet, wait until we are, or until an error
// occurs.
- while (d->state != Connected && d->socket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) {
+ while (d->state != Connected && d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
// Loop while the protocol handshake is taking place.
}
@@ -403,7 +391,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
// If we're not connected yet, wait until we are, and until bytes have
// been received (i.e., the socket has connected, we have sent the
// greeting, and then received the response).
- while (d->state != Connected && d->socket->waitForReadyRead(qt_timeout_value(msecs, stopWatch.elapsed()))) {
+ while (d->state != Connected && d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
// Loop while the protocol handshake is taking place.
}