summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2020-02-27 05:23:39 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2020-03-31 12:51:07 +0300
commite37c80b52f93a8861ae93481fc672db3924c8f59 (patch)
tree29c10b20c85a5069a184a9a86d2ce8686a1b16ae
parentc72a47b7034d4fdb8ad722fc33de9e66af794faf (diff)
QMqttConnection: do not block when connecting with encryption
instead, postpone the transportConnectionEstablished() call from QSslSocket's Connected to Encrypted state Change-Id: I4ed146897c6b084c3dd19848655a3c28979175ba Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/mqtt/qmqttconnection.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp
index 3760c51..e7ea739 100644
--- a/src/mqtt/qmqttconnection.cpp
+++ b/src/mqtt/qmqttconnection.cpp
@@ -153,6 +153,11 @@ bool QMqttConnection::ensureTransport(bool createSecureIfNeeded)
#endif
QMqttClient::AbstractSocket;
+#ifndef QT_NO_SSL
+ if (QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket))
+ QObject::connect(sslSocket, &QSslSocket::encrypted, this, &QMqttConnection::transportConnectionEstablished);
+ else
+#endif
connect(socket, &QAbstractSocket::connected, this, &QMqttConnection::transportConnectionEstablished);
connect(socket, &QAbstractSocket::disconnected, this, &QMqttConnection::transportConnectionClosed);
connect(socket, static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
@@ -199,16 +204,6 @@ bool QMqttConnection::ensureTransportOpen(const QString &sslPeerName)
if (!m_sslConfiguration.isNull())
socket->setSslConfiguration(m_sslConfiguration);
socket->connectToHostEncrypted(m_clientPrivate->m_hostname, m_clientPrivate->m_port, sslPeerName);
-
- if (!socket->waitForConnected()) {
- qCDebug(lcMqttConnection) << "Could not establish socket connection for transport.";
- return false;
- }
-
- if (!socket->waitForEncrypted()) {
- qCDebug(lcMqttConnection) << "Could not initiate encryption.";
- return false;
- }
}
#else
Q_UNUSED(sslPeerName);