summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2011-03-16 12:06:08 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2011-03-16 13:38:20 (GMT)
commitfd009286dfcea0a849d85c824f214e640c4d4ce2 (patch)
tree6f4757b8a277dc8c0c72fb0432254661b9995175
parent3a2bb048b49e8d009d785ddd4c0ed221766cc11e (diff)
downloadQt-fd009286dfcea0a849d85c824f214e640c4d4ce2.zip
Qt-fd009286dfcea0a849d85c824f214e640c4d4ce2.tar.gz
Qt-fd009286dfcea0a849d85c824f214e640c4d4ce2.tar.bz2
QTcpSocket: Fix for disconnect in Unbuffered mode.
We need to set the state properly after we have been disconnected. Also fix the HTTP layer, it needs to handle the disconnect when reading. Reviewed-by: Peter Hartmann
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp13
-rw-r--r--src/network/socket/qabstractsocket.cpp2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 6a05fd3..62c6fab 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -915,15 +915,18 @@ bool QHttpNetworkConnectionChannel::isSocketReading() const
//private slots
void QHttpNetworkConnectionChannel::_q_readyRead()
{
- // We got a readyRead but no bytes are available..
- // This happens for the Unbuffered QTcpSocket
- // Also check if socket is in ConnectedState since
- // this function may also be invoked via the event loop.
if (socket->state() == QAbstractSocket::ConnectedState && socket->bytesAvailable() == 0) {
+ // We got a readyRead but no bytes are available..
+ // This happens for the Unbuffered QTcpSocket
+ // Also check if socket is in ConnectedState since
+ // this function may also be invoked via the event loop.
char c;
qint64 ret = socket->peek(&c, 1);
if (ret < 0) {
- socket->disconnectFromHost();
+ _q_error(socket->error());
+ // We still need to handle the reply so it emits its signals etc.
+ if (reply)
+ _q_receiveReply();
return;
}
}
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 2a942cc..c7c2e82 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -2210,6 +2210,8 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
} else if (readBytes < 0) {
d->socketError = d->socketEngine->error();
setErrorString(d->socketEngine->errorString());
+ d->resetSocketLayer();
+ d->state = QAbstractSocket::UnconnectedState;
} else if (!d->socketEngine->isReadNotificationEnabled()) {
// Only do this when there was no error
d->socketEngine->setReadNotificationEnabled(true);