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 <timur.pocheptsov@qt.io>
This commit is contained in:
Mårten Nordheim 2019-03-04 12:24:10 +01:00
parent 7831b276e6
commit e431a3ac02

View File

@ -966,7 +966,10 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
} else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) { } else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) {
// Try to reconnect/resend before sending an error. // Try to reconnect/resend before sending an error.
// While "Reading" the _q_disconnected() will handle this. // 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(); resendCurrentRequest();
return; return;
} else { } else {