Clear read- and write buffers
Added calls to clear the write and read buffers when - setSocketDescriptor is called - abort is called Removed clears the read and write buffers from the documentation of resetSocketLayer. Added documentation to setSocketDescriptor describing that read and write buffers are cleared. Task-number: QTBUG-28914 Change-Id: I25a4b679708bdea0b259c50f1d10a3e9271dabb9 Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
parent
7c11e7ec19
commit
3169863ace
@ -578,8 +578,7 @@ QAbstractSocketPrivate::~QAbstractSocketPrivate()
|
|||||||
|
|
||||||
/*! \internal
|
/*! \internal
|
||||||
|
|
||||||
Resets the socket layer, clears the read and write buffers and
|
Resets the socket layer and deletes any socket notifiers.
|
||||||
deletes any socket notifiers.
|
|
||||||
*/
|
*/
|
||||||
void QAbstractSocketPrivate::resetSocketLayer()
|
void QAbstractSocketPrivate::resetSocketLayer()
|
||||||
{
|
{
|
||||||
@ -1821,6 +1820,7 @@ qintptr QAbstractSocket::socketDescriptor() const
|
|||||||
as a valid socket descriptor; otherwise returns \c false.
|
as a valid socket descriptor; otherwise returns \c false.
|
||||||
The socket is opened in the mode specified by \a openMode, and
|
The socket is opened in the mode specified by \a openMode, and
|
||||||
enters the socket state specified by \a socketState.
|
enters the socket state specified by \a socketState.
|
||||||
|
Read and write buffers are cleared, discarding any pending data.
|
||||||
|
|
||||||
\b{Note:} It is not possible to initialize two abstract sockets
|
\b{Note:} It is not possible to initialize two abstract sockets
|
||||||
with the same native socket descriptor.
|
with the same native socket descriptor.
|
||||||
@ -1833,6 +1833,8 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
|
|||||||
Q_D(QAbstractSocket);
|
Q_D(QAbstractSocket);
|
||||||
|
|
||||||
d->resetSocketLayer();
|
d->resetSocketLayer();
|
||||||
|
d->writeBuffer.clear();
|
||||||
|
d->buffer.clear();
|
||||||
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
|
d->socketEngine = QAbstractSocketEngine::createSocketEngine(socketDescriptor, this);
|
||||||
if (!d->socketEngine) {
|
if (!d->socketEngine) {
|
||||||
d->socketError = UnsupportedSocketOperationError;
|
d->socketError = UnsupportedSocketOperationError;
|
||||||
@ -2281,6 +2283,7 @@ void QAbstractSocket::abort()
|
|||||||
#if defined (QABSTRACTSOCKET_DEBUG)
|
#if defined (QABSTRACTSOCKET_DEBUG)
|
||||||
qDebug("QAbstractSocket::abort()");
|
qDebug("QAbstractSocket::abort()");
|
||||||
#endif
|
#endif
|
||||||
|
d->writeBuffer.clear();
|
||||||
if (d->state == UnconnectedState)
|
if (d->state == UnconnectedState)
|
||||||
return;
|
return;
|
||||||
#ifndef QT_NO_SSL
|
#ifndef QT_NO_SSL
|
||||||
@ -2295,7 +2298,6 @@ void QAbstractSocket::abort()
|
|||||||
d->connectTimer = 0;
|
d->connectTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->writeBuffer.clear();
|
|
||||||
d->abortCalled = true;
|
d->abortCalled = true;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user