Remove QSslSocket::abort()
QAbstractSocket::abort() is not a virtual function and QSslSocket::abort() does not override it. Having two alternatives requires a dynamic typecasting and violates the principles of object- oriented programming. Due to the BC, we were unable to fix that in Qt5. Now, we can modify QSslSocket::close() to handle QAbstractSocket::abort() requests and remove the duplicate. Change-Id: I49d6f32a571ae6e35b08cb366816f917e580dae8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
0a12416172
commit
c0097d1521
@ -479,10 +479,6 @@
|
|||||||
#include <qscopedvaluerollback.h>
|
#include <qscopedvaluerollback.h>
|
||||||
#include <qvarlengtharray.h>
|
#include <qvarlengtharray.h>
|
||||||
|
|
||||||
#ifndef QT_NO_SSL
|
|
||||||
#include <QtNetwork/qsslsocket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <private/qthread_p.h>
|
#include <private/qthread_p.h>
|
||||||
|
|
||||||
#ifdef QABSTRACTSOCKET_DEBUG
|
#ifdef QABSTRACTSOCKET_DEBUG
|
||||||
@ -2406,13 +2402,6 @@ void QAbstractSocket::abort()
|
|||||||
qDebug("QAbstractSocket::abort()");
|
qDebug("QAbstractSocket::abort()");
|
||||||
#endif
|
#endif
|
||||||
d->setWriteChannelCount(0);
|
d->setWriteChannelCount(0);
|
||||||
#ifndef QT_NO_SSL
|
|
||||||
if (QSslSocket *socket = qobject_cast<QSslSocket *>(this)) {
|
|
||||||
socket->abort();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
d->abortCalled = true;
|
d->abortCalled = true;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -899,13 +899,19 @@ void QSslSocket::close()
|
|||||||
#endif
|
#endif
|
||||||
Q_D(QSslSocket);
|
Q_D(QSslSocket);
|
||||||
|
|
||||||
// We don't want any CA roots fetched anymore.
|
// On Windows, CertGetCertificateChain is probably still doing its
|
||||||
|
// job, if the socket is re-used, we want to ignore its reported
|
||||||
|
// root CA.
|
||||||
d->caToFetch = QSslCertificate{};
|
d->caToFetch = QSslCertificate{};
|
||||||
|
|
||||||
if (encryptedBytesToWrite() || !d->writeBuffer.isEmpty())
|
if (!d->abortCalled && (encryptedBytesToWrite() || !d->writeBuffer.isEmpty()))
|
||||||
flush();
|
flush();
|
||||||
if (d->plainSocket)
|
if (d->plainSocket) {
|
||||||
|
if (d->abortCalled)
|
||||||
|
d->plainSocket->abort();
|
||||||
|
else
|
||||||
d->plainSocket->close();
|
d->plainSocket->close();
|
||||||
|
}
|
||||||
QTcpSocket::close();
|
QTcpSocket::close();
|
||||||
|
|
||||||
// must be cleared, reading/writing not possible on closed socket:
|
// must be cleared, reading/writing not possible on closed socket:
|
||||||
@ -938,29 +944,6 @@ void QSslSocket::setReadBufferSize(qint64 size)
|
|||||||
d->plainSocket->setReadBufferSize(size);
|
d->plainSocket->setReadBufferSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Aborts the current connection and resets the socket. Unlike
|
|
||||||
disconnectFromHost(), this function immediately closes the socket,
|
|
||||||
clearing any pending data in the write buffer.
|
|
||||||
|
|
||||||
\sa disconnectFromHost(), close()
|
|
||||||
*/
|
|
||||||
void QSslSocket::abort()
|
|
||||||
{
|
|
||||||
Q_D(QSslSocket);
|
|
||||||
#ifdef QSSLSOCKET_DEBUG
|
|
||||||
qCDebug(lcSsl) << "QSslSocket::abort()";
|
|
||||||
#endif
|
|
||||||
// On Windows, CertGetCertificateChain is probably still doing its
|
|
||||||
// job, if the socket is re-used, we want to ignore its reported
|
|
||||||
// root CA.
|
|
||||||
d->caToFetch = QSslCertificate{};
|
|
||||||
|
|
||||||
if (d->plainSocket)
|
|
||||||
d->plainSocket->abort();
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\since 4.4
|
\since 4.4
|
||||||
|
|
||||||
@ -1883,6 +1866,7 @@ void QSslSocketPrivate::init()
|
|||||||
connectionEncrypted = false;
|
connectionEncrypted = false;
|
||||||
ignoreAllSslErrors = false;
|
ignoreAllSslErrors = false;
|
||||||
shutdown = false;
|
shutdown = false;
|
||||||
|
abortCalled = false;
|
||||||
pendingClose = false;
|
pendingClose = false;
|
||||||
flushTriggered = false;
|
flushTriggered = false;
|
||||||
ocspResponses.clear();
|
ocspResponses.clear();
|
||||||
|
@ -117,7 +117,6 @@ public:
|
|||||||
bool canReadLine() const override;
|
bool canReadLine() const override;
|
||||||
void close() override;
|
void close() override;
|
||||||
bool atEnd() const override;
|
bool atEnd() const override;
|
||||||
void abort();
|
|
||||||
|
|
||||||
// From QAbstractSocket:
|
// From QAbstractSocket:
|
||||||
void setReadBufferSize(qint64 size) override;
|
void setReadBufferSize(qint64 size) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user