summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-24 12:18:17 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-24 12:23:20 (GMT)
commit211bea9838bcc2acd7f54b65468fe1be2d81b1e0 (patch)
tree9ea9159a3235a82b5af4de6de22789375bd7af48 /src/network
parentfc0c0621d8c5ffb89e4f9c72fa706b3f10aea97e (diff)
downloadQt-211bea9838bcc2acd7f54b65468fe1be2d81b1e0.zip
Qt-211bea9838bcc2acd7f54b65468fe1be2d81b1e0.tar.gz
Qt-211bea9838bcc2acd7f54b65468fe1be2d81b1e0.tar.bz2
Re-send network request properly when the socket is in Closing state.
This fixes the "QAbstractSocket::connectToHost() called when already connecting/connected to <hostname>". The issue was that we were trying to call connect on a socket that was in a Closing state. We have to wait for the disconnected signal before we try to connect again. Reviewed-by: Prasanth
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 980c0e0..5940fba 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -265,6 +265,11 @@ bool QHttpNetworkConnectionPrivate::ensureConnection(QAbstractSocket *socket)
if (socket->state() != QAbstractSocket::ConnectedState) {
// connect to the host if not already connected.
int index = indexOf(socket);
+ // resend this request after we receive the disconnected signal
+ if (socket->state() == QAbstractSocket::ClosingState) {
+ channels[index].resendCurrent = true;
+ return false;
+ }
channels[index].state = ConnectingState;
channels[index].pendingEncrypt = encrypt;
@@ -982,6 +987,9 @@ void QHttpNetworkConnectionPrivate::_q_disconnected()
channels[i].state = ReadingState;
if (channels[i].reply)
receiveReply(socket, channels[i].reply);
+ } else if (channels[i].state == IdleState && channels[i].resendCurrent) {
+ // re-sending request because the socket was in ClosingState
+ QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
}
channels[i].state = IdleState;
}