summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslsocket.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-30 08:43:14 +0100
committerLiang Qi <liang.qi@qt.io>2017-10-30 08:54:05 +0100
commit17d51411132edef53e79dcbaf1046f06f79bed5d (patch)
tree38398d448b30313f91960c70a3a28cce91293da9 /src/network/ssl/qsslsocket.cpp
parentea0e868c4881944207e9b3a77011e05a505ff3b7 (diff)
parent9f0dda29d5d070f63b7f098139f01f07ec91ffdf (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/plugins/platforms/windows/qwindowswindow.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ia017a825ed2ca2d53ac586f4ae48df6f65818d40
Diffstat (limited to 'src/network/ssl/qsslsocket.cpp')
-rw-r--r--src/network/ssl/qsslsocket.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 5c9ebac283..adff568f5b 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1686,7 +1686,8 @@ bool QSslSocket::waitForDisconnected(int msecs)
if (!d->plainSocket)
return false;
- if (d->mode == UnencryptedMode)
+ // Forward to the plain socket unless the connection is secure.
+ if (d->mode == UnencryptedMode && !d->autoStartHandshake)
return d->plainSocket->waitForDisconnected(msecs);
QElapsedTimer stopWatch;
@@ -1697,6 +1698,17 @@ bool QSslSocket::waitForDisconnected(int msecs)
if (!waitForEncrypted(msecs))
return false;
}
+ // We are delaying the disconnect, if the write buffer is not empty.
+ // So, start the transmission.
+ if (!d->writeBuffer.isEmpty())
+ d->transmit();
+
+ // At this point, the socket might be disconnected, if disconnectFromHost()
+ // was called just after the connectToHostEncrypted() call. Also, we can
+ // lose the connection as a result of the transmit() call.
+ if (state() == UnconnectedState)
+ return true;
+
bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
if (!retVal) {
setSocketState(d->plainSocket->state());