QSslSocket: Allow disconnections within the connected() signal

When doing happy eyeballs style network state lookup, we might have to
close an SSL socket from its connected signal. This can cause the warning:
QSslSocket::startClientEncryption: cannot start handshake when not connected

The signal should be emitted after we called startClientEncryption to
avoid this warning. In that case it will initialize the encryption
and ramp it down right after.

Change-Id: I0c8c79cad7f91f0088b87c5e4ee8aafbc688411c
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
This commit is contained in:
Jocelyn Turcotte 2012-10-16 18:25:01 +02:00 committed by The Qt Project
parent a26c97859a
commit ed19c0875e

View File

@ -2153,11 +2153,13 @@ void QSslSocketPrivate::_q_connectedSlot()
qDebug() << "\tlocal =" << QHostInfo::fromName(q->localAddress().toString()).hostName()
<< q->localAddress() << q->localPort();
#endif
if (autoStartHandshake)
q->startClientEncryption();
emit q->connected();
if (autoStartHandshake) {
q->startClientEncryption();
} else if (pendingClose) {
if (pendingClose && !autoStartHandshake) {
pendingClose = false;
q->disconnectFromHost();
}