summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslsocket.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-07-31 19:33:41 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2020-08-20 08:33:09 +0300
commitc0097d1521383ce49956c9f4da8be01ad178f43e (patch)
treeb7b665ebafeda21840de451eda06fae45326424e /src/network/ssl/qsslsocket.cpp
parent0a1241617255d54a3616420d69dd2fa9ade99b4d (diff)
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>
Diffstat (limited to 'src/network/ssl/qsslsocket.cpp')
-rw-r--r--src/network/ssl/qsslsocket.cpp38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 19ab903d36..9d8fa035e2 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -899,13 +899,19 @@ void QSslSocket::close()
#endif
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{};
- if (encryptedBytesToWrite() || !d->writeBuffer.isEmpty())
+ if (!d->abortCalled && (encryptedBytesToWrite() || !d->writeBuffer.isEmpty()))
flush();
- if (d->plainSocket)
- d->plainSocket->close();
+ if (d->plainSocket) {
+ if (d->abortCalled)
+ d->plainSocket->abort();
+ else
+ d->plainSocket->close();
+ }
QTcpSocket::close();
// must be cleared, reading/writing not possible on closed socket:
@@ -939,29 +945,6 @@ void QSslSocket::setReadBufferSize(qint64 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
Returns the socket's SSL configuration state. The default SSL
@@ -1883,6 +1866,7 @@ void QSslSocketPrivate::init()
connectionEncrypted = false;
ignoreAllSslErrors = false;
shutdown = false;
+ abortCalled = false;
pendingClose = false;
flushTriggered = false;
ocspResponses.clear();