diff options
author | Martin Petersson <martin.petersson@nokia.com> | 2011-03-04 11:13:20 (GMT) |
---|---|---|
committer | Martin Petersson <martin.petersson@nokia.com> | 2011-03-04 11:16:51 (GMT) |
commit | 7458c4bb9a0f6f925cb6002d3b664bbbc21e75ef (patch) | |
tree | 6d2ff904d2882caa753e0657c0af9a2049b97edf /src/network | |
parent | b2544e10f4b575b41ff91ad72d2d7186ac3109e5 (diff) | |
download | Qt-7458c4bb9a0f6f925cb6002d3b664bbbc21e75ef.zip Qt-7458c4bb9a0f6f925cb6002d3b664bbbc21e75ef.tar.gz Qt-7458c4bb9a0f6f925cb6002d3b664bbbc21e75ef.tar.bz2 |
QNAM HTTP: Fix the ioPostToHttpFromSocket auto test
Introduced a ClosingState for the channel to better track the state
of the socket.
Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 20 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel_p.h | 3 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 3502113..35c3a67 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -765,7 +765,7 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() //resend the necessary ones. for (int i = 0; i < channelCount; ++i) { - if (channels[i].resendCurrent) { + if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) { channels[i].resendCurrent = false; channels[i].state = QHttpNetworkConnectionChannel::IdleState; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 41bc64a..60094b0 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -145,10 +145,12 @@ void QHttpNetworkConnectionChannel::init() void QHttpNetworkConnectionChannel::close() { - socket->blockSignals(true); + if (socket->state() == QAbstractSocket::UnconnectedState) + state = QHttpNetworkConnectionChannel::IdleState; + else + state = QHttpNetworkConnectionChannel::ClosingState; + socket->close(); - socket->blockSignals(false); - state = QHttpNetworkConnectionChannel::IdleState; } @@ -679,7 +681,8 @@ void QHttpNetworkConnectionChannel::allDone() reconnectAttempts = 2; // now the channel can be seen as free/idle again, all signal emissions for the reply have been done - this->state = QHttpNetworkConnectionChannel::IdleState; + if (state != QHttpNetworkConnectionChannel::ClosingState) + state = QHttpNetworkConnectionChannel::IdleState; // if it does not need to be sent again we can set it to 0 // the previous code did not do that and we had problems with accidental re-sending of a @@ -729,7 +732,8 @@ void QHttpNetworkConnectionChannel::allDone() QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else if (alreadyPipelinedRequests.isEmpty()) { if (connectionCloseEnabled) - close(); + if (socket->state() != QAbstractSocket::UnconnectedState) + close(); if (qobject_cast<QHttpNetworkConnection*>(connection)) QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } @@ -936,6 +940,12 @@ void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes) void QHttpNetworkConnectionChannel::_q_disconnected() { + if (state == QHttpNetworkConnectionChannel::ClosingState) { + state = QHttpNetworkConnectionChannel::IdleState; + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + return; + } + // read the available data before closing if (isSocketWaiting() || isSocketReading()) { if (reply) { diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 8cbc689..893d75e 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -95,7 +95,8 @@ public: WritingState = 2, // writing the data WaitingState = 4, // waiting for reply ReadingState = 8, // reading the reply - BusyState = (ConnectingState|WritingState|WaitingState|ReadingState) + ClosingState = 16, + BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|ClosingState) }; QAbstractSocket *socket; bool ssl; |