summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qabstractsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r--src/network/socket/qabstractsocket.cpp316
1 files changed, 166 insertions, 150 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index e60c821da6..c6f5b8864b 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1,31 +1,38 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -461,6 +468,7 @@
#include <qtimer.h>
#include <qelapsedtimer.h>
#include <qscopedvaluerollback.h>
+#include <qvarlengtharray.h>
#ifndef QT_NO_SSL
#include <QtNetwork/qsslsocket.h>
@@ -543,10 +551,7 @@ static bool isProxyError(QAbstractSocket::SocketError error)
Constructs a QAbstractSocketPrivate. Initializes all members.
*/
QAbstractSocketPrivate::QAbstractSocketPrivate()
- : readSocketNotifierCalled(false),
- readSocketNotifierState(false),
- readSocketNotifierStateSet(false),
- emittedReadyRead(false),
+ : emittedReadyRead(false),
emittedBytesWritten(false),
abortCalled(false),
pendingClose(false),
@@ -557,17 +562,16 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
socketEngine(0),
cachedSocketDescriptor(-1),
readBufferMaxSize(0),
- writeBuffer(QABSTRACTSOCKET_BUFFERSIZE),
isBuffered(false),
connectTimer(0),
disconnectTimer(0),
- connectTimeElapsed(0),
hostLookupId(-1),
socketType(QAbstractSocket::UnknownSocketType),
state(QAbstractSocket::UnconnectedState),
socketError(QAbstractSocket::UnknownSocketError),
preferredNetworkLayerProtocol(QAbstractSocket::UnknownNetworkLayerProtocol)
{
+ writeBufferChunkSize = QABSTRACTSOCKET_BUFFERSIZE;
}
/*! \internal
@@ -679,17 +683,6 @@ bool QAbstractSocketPrivate::canReadNotification()
qDebug("QAbstractSocketPrivate::canReadNotification()");
#endif
- // Prevent recursive calls
- if (readSocketNotifierCalled) {
- if (!readSocketNotifierStateSet) {
- readSocketNotifierStateSet = true;
- readSocketNotifierState = socketEngine->isReadNotificationEnabled();
- socketEngine->setReadNotificationEnabled(false);
- }
- }
- QScopedValueRollback<bool> rsncrollback(readSocketNotifierCalled);
- readSocketNotifierCalled = true;
-
if (!isBuffered)
socketEngine->setReadNotificationEnabled(false);
@@ -722,19 +715,9 @@ bool QAbstractSocketPrivate::canReadNotification()
}
}
- // only emit readyRead() when not recursing, and only if there is data available
- bool hasData = newBytes > 0
-#ifndef QT_NO_UDPSOCKET
- || (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams())
-#endif
- || (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine)
- ;
-
- if (!emittedReadyRead && hasData) {
- QScopedValueRollback<bool> r(emittedReadyRead);
- emittedReadyRead = true;
- emit q->readyRead();
- }
+ // Only emit readyRead() if there is data available.
+ if (newBytes > 0 || !isBuffered)
+ emitReadyRead();
// If we were closed as a result of the readyRead() signal,
// return.
@@ -749,13 +732,6 @@ bool QAbstractSocketPrivate::canReadNotification()
if (socketEngine && isBuffered)
socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
- // reset the read socket notifier state if we reentered inside the
- // readyRead() connected slot.
- if (readSocketNotifierStateSet && socketEngine &&
- readSocketNotifierState != socketEngine->isReadNotificationEnabled()) {
- socketEngine->setReadNotificationEnabled(readSocketNotifierState);
- readSocketNotifierStateSet = false;
- }
return true;
}
@@ -792,12 +768,12 @@ void QAbstractSocketPrivate::canCloseNotification()
// then occur when we read from the socket again and fail
// in canReadNotification or by the manually created
// closeNotification below.
- emit q->readyRead();
+ emitReadyRead();
QMetaObject::invokeMethod(socketEngine, "closeNotification", Qt::QueuedConnection);
}
} else if (socketType == QAbstractSocket::TcpSocket && socketEngine) {
- emit q->readyRead();
+ emitReadyRead();
}
}
@@ -809,28 +785,15 @@ void QAbstractSocketPrivate::canCloseNotification()
*/
bool QAbstractSocketPrivate::canWriteNotification()
{
-#if defined (Q_OS_WIN)
- if (socketEngine && socketEngine->isWriteNotificationEnabled())
- socketEngine->setWriteNotificationEnabled(false);
-#endif
-
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
#endif
- qint64 tmp = writeBuffer.size();
- flush();
+ bool dataWasWritten = writeToSocket();
- if (socketEngine) {
-#if defined (Q_OS_WIN)
- if (!writeBuffer.isEmpty())
- socketEngine->setWriteNotificationEnabled(true);
-#else
- if (writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
- socketEngine->setWriteNotificationEnabled(false);
-#endif
- }
+ if (socketEngine && writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
+ socketEngine->setWriteNotificationEnabled(false);
- return (writeBuffer.size() < tmp);
+ return dataWasWritten;
}
/*! \internal
@@ -852,21 +815,20 @@ void QAbstractSocketPrivate::connectionNotification()
/*! \internal
- Writes pending data in the write buffers to the socket. The
- function writes as much as it can without blocking.
+ Writes one pending data block in the write buffer to the socket.
It is usually invoked by canWriteNotification after one or more
calls to write().
Emits bytesWritten().
*/
-bool QAbstractSocketPrivate::flush()
+bool QAbstractSocketPrivate::writeToSocket()
{
Q_Q(QAbstractSocket);
if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty()
&& socketEngine->bytesToWrite() == 0)) {
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::flush() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
+ qDebug("QAbstractSocketPrivate::writeToSocket() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
(socketEngine && socketEngine->isValid()) ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no");
#endif
@@ -884,7 +846,8 @@ bool QAbstractSocketPrivate::flush()
qint64 written = socketEngine->write(ptr, nextSize);
if (written < 0) {
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug() << "QAbstractSocketPrivate::flush() write error, aborting." << socketEngine->errorString();
+ qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting."
+ << socketEngine->errorString();
#endif
setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
// an unexpected error so close the socket.
@@ -893,19 +856,20 @@ bool QAbstractSocketPrivate::flush()
}
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::flush() %lld bytes written to the network",
+ qDebug("QAbstractSocketPrivate::writeToSocket() %lld bytes written to the network",
written);
#endif
- // Remove what we wrote so far.
- writeBuffer.free(written);
if (written > 0) {
+ // Remove what we wrote so far.
+ writeBuffer.free(written);
// Don't emit bytesWritten() recursively.
if (!emittedBytesWritten) {
QScopedValueRollback<bool> r(emittedBytesWritten);
emittedBytesWritten = true;
emit q->bytesWritten(written);
}
+ emit q->channelBytesWritten(0, written);
}
if (writeBuffer.isEmpty() && socketEngine && socketEngine->isWriteNotificationEnabled()
@@ -914,7 +878,23 @@ bool QAbstractSocketPrivate::flush()
if (state == QAbstractSocket::ClosingState)
q->disconnectFromHost();
- return true;
+ return written > 0;
+}
+
+/*! \internal
+
+ Writes pending data in the write buffers to the socket. The function
+ writes as much as it can without blocking. If any data was written,
+ this function returns true; otherwise false is returned.
+*/
+bool QAbstractSocketPrivate::flush()
+{
+ bool dataWasWritten = false;
+
+ while (!writeBuffer.isEmpty() && writeToSocket())
+ dataWasWritten = true;
+
+ return dataWasWritten;
}
#ifndef QT_NO_NETWORKPROXY
@@ -977,8 +957,6 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host)
state = QAbstractSocket::ConnectingState;
emit q->stateChanged(state);
- connectTimeElapsed = 0;
-
if (cachedSocketDescriptor != -1 || initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) {
if (socketEngine->connectToHostByName(host, port) ||
socketEngine->state() == QAbstractSocket::ConnectingState) {
@@ -1061,9 +1039,6 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
// Report the successful host lookup
emit q->hostFound();
- // Reset the total time spent connecting.
- connectTimeElapsed = 0;
-
// The addresses returned by the lookup will be tested one after
// another by _q_connectToNextAddress().
_q_connectToNextAddress();
@@ -1248,10 +1223,7 @@ void QAbstractSocketPrivate::_q_forceDisconnect()
*/
bool QAbstractSocketPrivate::readFromSocket()
{
-#ifdef QABSTRACTSOCKET_DEBUG
Q_Q(QAbstractSocket);
-#endif
-
// Find how many bytes we can read from the socket layer.
qint64 bytesToRead = socketEngine->bytesAvailable();
if (bytesToRead == 0) {
@@ -1264,27 +1236,39 @@ bool QAbstractSocketPrivate::readFromSocket()
// host has _not_ disappeared).
bytesToRead = 4096;
}
- if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size()))
- bytesToRead = readBufferMaxSize - buffer.size();
+
+ if (q->isReadable()) {
+ if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size()))
+ bytesToRead = readBufferMaxSize - buffer.size();
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::readFromSocket() about to read %lld bytes",
- bytesToRead);
+ qDebug("QAbstractSocketPrivate::readFromSocket() about to read %lld bytes",
+ bytesToRead);
#endif
- // Read from the socket, store data in the read buffer.
- char *ptr = buffer.reserve(bytesToRead);
- qint64 readBytes = socketEngine->read(ptr, bytesToRead);
- if (readBytes == -2) {
- // No bytes currently available for reading.
- buffer.chop(bytesToRead);
- return true;
- }
- buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes));
+ // Read from the socket, store data in the read buffer.
+ char *ptr = buffer.reserve(bytesToRead);
+ qint64 readBytes = socketEngine->read(ptr, bytesToRead);
+ if (readBytes == -2) {
+ // No bytes currently available for reading.
+ buffer.chop(bytesToRead);
+ return true;
+ }
+ buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes));
+#if defined(QABSTRACTSOCKET_DEBUG)
+ qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld",
+ readBytes, buffer.size());
+#endif
+ } else {
+ // Discard unwanted data if opened in WriteOnly mode
+ QVarLengthArray<char, 4096> discardBuffer(bytesToRead);
+
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld",
- readBytes, buffer.size());
+ qDebug("QAbstractSocketPrivate::readFromSocket() about to discard %lld bytes",
+ bytesToRead);
#endif
+ socketEngine->read(discardBuffer.data(), bytesToRead);
+ }
if (!socketEngine->isValid()) {
setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
@@ -1301,6 +1285,22 @@ bool QAbstractSocketPrivate::readFromSocket()
/*! \internal
+ Prevents from the recursive readyRead() emission.
+*/
+void QAbstractSocketPrivate::emitReadyRead()
+{
+ Q_Q(QAbstractSocket);
+ // Only emit readyRead() when not recursing.
+ if (!emittedReadyRead) {
+ QScopedValueRollback<bool> r(emittedReadyRead);
+ emittedReadyRead = true;
+ emit q->readyRead();
+ }
+ emit q->channelReadyRead(0);
+}
+
+/*! \internal
+
Sets up the internal state after the connection has succeeded.
*/
void QAbstractSocketPrivate::fetchConnectionParameters()
@@ -1309,6 +1309,18 @@ void QAbstractSocketPrivate::fetchConnectionParameters()
peerName = hostName;
if (socketEngine) {
+ if (q->isReadable()) {
+ const int inboundStreamCount = socketEngine->inboundStreamCount();
+ setReadChannelCount(qMax(1, inboundStreamCount));
+ if (inboundStreamCount == 0)
+ readChannelCount = 0;
+ }
+ if (q->isWritable()) {
+ const int outboundStreamCount = socketEngine->outboundStreamCount();
+ setWriteChannelCount(qMax(1, outboundStreamCount));
+ if (outboundStreamCount == 0)
+ writeChannelCount = 0;
+ }
socketEngine->setReadNotificationEnabled(true);
socketEngine->setWriteNotificationEnabled(true);
localPort = socketEngine->localPort();
@@ -1631,8 +1643,8 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
d->preferredNetworkLayerProtocol = protocol;
d->hostName = hostName;
d->port = port;
- d->buffer.clear();
- d->writeBuffer.clear();
+ d->setReadChannelCount(0);
+ d->setWriteChannelCount(0);
d->abortCalled = false;
d->pendingClose = false;
if (d->state != BoundState) {
@@ -1665,6 +1677,8 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
openMode |= QAbstractSocket::Unbuffered; // QUdpSocket
QIODevice::open(openMode);
+ d->readChannelCount = d->writeChannelCount = 0;
+
d->state = HostLookupState;
emit stateChanged(d->state);
@@ -1727,11 +1741,11 @@ void QAbstractSocket::connectToHost(const QHostAddress &address, quint16 port,
*/
qint64 QAbstractSocket::bytesToWrite() const
{
- Q_D(const QAbstractSocket);
+ const qint64 pendingBytes = QIODevice::bytesToWrite();
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::bytesToWrite() == %lld", d->writeBuffer.size());
+ qDebug("QAbstractSocket::bytesToWrite() == %lld", pendingBytes);
#endif
- return d->writeBuffer.size();
+ return pendingBytes;
}
/*!
@@ -1870,8 +1884,8 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
Q_D(QAbstractSocket);
d->resetSocketLayer();
- d->writeBuffer.clear();
- d->buffer.clear();
+ d->setReadChannelCount(0);
+ d->setWriteChannelCount(0);
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
if (!d->socketEngine) {
d->setError(UnsupportedSocketOperationError, tr("Operation on socket is not supported"));
@@ -1892,6 +1906,23 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
QIODevice::open(openMode);
+ if (socketState == ConnectedState) {
+ if (isReadable()) {
+ const int inboundStreamCount = d->socketEngine->inboundStreamCount();
+ d->setReadChannelCount(qMax(1, inboundStreamCount));
+ if (inboundStreamCount == 0)
+ d->readChannelCount = 0;
+ }
+ if (isWritable()) {
+ const int outboundStreamCount = d->socketEngine->outboundStreamCount();
+ d->setWriteChannelCount(qMax(1, outboundStreamCount));
+ if (outboundStreamCount == 0)
+ d->writeChannelCount = 0;
+ }
+ } else {
+ d->readChannelCount = d->writeChannelCount = 0;
+ }
+
if (d->state != socketState) {
d->state = socketState;
emit stateChanged(d->state);
@@ -2338,7 +2369,7 @@ void QAbstractSocket::abort()
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::abort()");
#endif
- d->writeBuffer.clear();
+ d->setWriteChannelCount(0);
if (d->state == UnconnectedState)
return;
#ifndef QT_NO_SSL
@@ -2378,7 +2409,7 @@ bool QAbstractSocket::isSequential() const
*/
bool QAbstractSocket::atEnd() const
{
- return QIODevice::atEnd() && (!isOpen() || d_func()->buffer.isEmpty());
+ return QIODevice::atEnd();
}
/*!
@@ -2415,30 +2446,17 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
{
Q_D(QAbstractSocket);
- // Check if the read notifier can be enabled again.
- if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid())
- d->socketEngine->setReadNotificationEnabled(true);
+ // if we're not connected, return -1 indicating EOF
+ if (!d->socketEngine || !d->socketEngine->isValid() || d->state != QAbstractSocket::ConnectedState)
+ return maxSize ? qint64(-1) : qint64(0);
- if (!maxSize)
- return 0;
-
- // This is for a buffered QTcpSocket
- if (d->isBuffered)
- // if we're still connected, return 0 indicating there may be more data in the future
- // if we're not connected, return -1 indicating EOF
- return d->state == QAbstractSocket::ConnectedState ? qint64(0) : qint64(-1);
-
- if (!d->socketEngine)
- return -1; // no socket engine is probably EOF
- if (!d->socketEngine->isValid())
- return -1; // This is for unbuffered TCP when we already had been disconnected
- if (d->state != QAbstractSocket::ConnectedState)
- return -1; // This is for unbuffered TCP if we're not connected yet
- qint64 readBytes = d->socketEngine->read(data, maxSize);
+ qint64 readBytes = (maxSize && !d->isBuffered) ? d->socketEngine->read(data, maxSize)
+ : qint64(0);
if (readBytes == -2) {
// -2 from the engine means no bytes available (EAGAIN) so read more later
- return 0;
- } else if (readBytes < 0) {
+ readBytes = 0;
+ }
+ if (readBytes < 0) {
d->setError(d->socketEngine->error(), d->socketEngine->errorString());
d->resetSocketLayer();
d->state = QAbstractSocket::UnconnectedState;
@@ -2453,7 +2471,6 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
readBytes);
#endif
return readBytes;
-
}
/*! \reimp
@@ -2480,30 +2497,34 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
qint64 written = d->socketEngine->write(data, size);
if (written < 0) {
d->setError(d->socketEngine->error(), d->socketEngine->errorString());
- return written;
} else if (written < size) {
// Buffer what was not written yet
- char *ptr = d->writeBuffer.reserve(size - written);
- memcpy(ptr, data + written, size - written);
+ d->writeBuffer.append(data + written, size - written);
+ written = size;
d->socketEngine->setWriteNotificationEnabled(true);
}
- return size; // size=actually written + what has been buffered
+
+#if defined (QABSTRACTSOCKET_DEBUG)
+ qDebug("QAbstractSocket::writeData(%p \"%s\", %lli) == %lli", data,
+ qt_prettyDebug(data, qMin((int)size, 32), size).data(),
+ size, written);
+#endif
+ return written; // written = actually written + what has been buffered
} else if (!d->isBuffered && d->socketType != TcpSocket) {
// This is for a QUdpSocket that was connect()ed
qint64 written = d->socketEngine->write(data, size);
- if (written < 0) {
+ if (written < 0)
d->setError(d->socketEngine->error(), d->socketEngine->errorString());
- } else if (!d->writeBuffer.isEmpty()) {
- d->socketEngine->setWriteNotificationEnabled(true);
- }
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::writeData(%p \"%s\", %lli) == %lli", data,
qt_prettyDebug(data, qMin((int)size, 32), size).data(),
size, written);
#endif
- if (written >= 0)
+ if (written >= 0) {
emit bytesWritten(written);
+ emit channelBytesWritten(0, written);
+ }
return written;
}
@@ -2513,12 +2534,7 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
// We just write to our write buffer and enable the write notifier
// The write notifier then flush()es the buffer.
- char *ptr = d->writeBuffer.reserve(size);
- if (size == 1)
- *ptr = *data;
- else
- memcpy(ptr, data, size);
-
+ d->writeBuffer.append(data, size);
qint64 written = size;
if (d->socketEngine && !d->writeBuffer.isEmpty())
@@ -2759,7 +2775,7 @@ void QAbstractSocket::disconnectFromHost()
d->peerPort = 0;
d->localAddress.clear();
d->peerAddress.clear();
- d->writeBuffer.clear();
+ d->setWriteChannelCount(0);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::disconnectFromHost() disconnected!");
@@ -2811,7 +2827,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
if (d->readBufferMaxSize == size)
return;
d->readBufferMaxSize = size;
- if (!d->readSocketNotifierCalled && d->socketEngine) {
+ if (!d->emittedReadyRead && d->socketEngine) {
// ensure that the read notification is enabled if we've now got
// room in the read buffer
// but only if we're not inside canReadNotification -- that will take care on its own