From e431a3ac027915dbfc0588f42f3b56e07639811e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 4 Mar 2019 12:24:10 +0100 Subject: [PATCH] Don't retry a ssl connection if encryption was never finished As explained in the inline comment we don't actually have a protocol handler until we're done encrypting when we use SSL, but we would still retry the connection if an error occurred between "connected" and "encrypted". This would then lead us to fail an assert that checked if a protocol handler had been set Fixes: QTBUG-47822 Change-Id: If7f4ef4f70e72b764f492e7ced5a9349b3a421d2 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 5726925cb0..d5f63af745 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -966,7 +966,10 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket } else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) { // Try to reconnect/resend before sending an error. // While "Reading" the _q_disconnected() will handle this. - if (reconnectAttempts-- > 0) { + // If we're using ssl then the protocolHandler is not initialized until + // "encrypted" has been emitted, since retrying requires the protocolHandler (asserted) + // we will not try if encryption is not done. + if (!pendingEncrypt && reconnectAttempts-- > 0) { resendCurrentRequest(); return; } else {