summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/ssl/qsslsocket.cpp')
-rw-r--r--src/network/ssl/qsslsocket.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 8eba5db9fe..833d676192 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -215,7 +215,7 @@
*/
/*!
- \fn QSslSocket::encrypted()
+ \fn void QSslSocket::encrypted()
This signal is emitted when QSslSocket enters encrypted mode. After this
signal has been emitted, QSslSocket::isEncrypted() will return true, and
@@ -225,7 +225,7 @@
*/
/*!
- \fn QSslSocket::modeChanged(QSslSocket::SslMode mode)
+ \fn void QSslSocket::modeChanged(QSslSocket::SslMode mode)
This signal is emitted when QSslSocket changes from \l
QSslSocket::UnencryptedMode to either \l QSslSocket::SslClientMode or \l
@@ -235,7 +235,7 @@
*/
/*!
- \fn QSslSocket::encryptedBytesWritten(qint64 written)
+ \fn void QSslSocket::encryptedBytesWritten(qint64 written)
\since 4.4
This signal is emitted when QSslSocket writes its encrypted data to the
@@ -922,6 +922,7 @@ void QSslSocket::setSslConfiguration(const QSslConfiguration &configuration)
d->configuration.peerVerifyDepth = configuration.peerVerifyDepth();
d->configuration.peerVerifyMode = configuration.peerVerifyMode();
d->configuration.protocol = configuration.protocol();
+ d->configuration.backendConfig = configuration.backendConfig();
d->configuration.sslOptions = configuration.d->sslOptions;
d->configuration.sslSession = configuration.sessionTicket();
d->configuration.sslSessionTicketLifeTimeHint = configuration.sessionTicketLifeTimeHint();
@@ -2005,6 +2006,8 @@ qint64 QSslSocket::readData(char *data, qint64 maxlen)
// possibly trigger another transmit() to decrypt more data from the socket
if (d->plainSocket->bytesAvailable())
QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection);
+ else if (d->state != QAbstractSocket::ConnectedState)
+ return maxlen ? qint64(-1) : qint64(0);
}
return readBytes;
@@ -2025,7 +2028,10 @@ qint64 QSslSocket::writeData(const char *data, qint64 len)
d->writeBuffer.append(data, len);
// make sure we flush to the plain socket's buffer
- QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection);
+ if (!d->flushTriggered) {
+ d->flushTriggered = true;
+ QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection);
+ }
return len;
}
@@ -2044,6 +2050,7 @@ QSslSocketPrivate::QSslSocketPrivate()
, allowRootCertOnDemandLoading(true)
, plainSocket(0)
, paused(false)
+ , flushTriggered(false)
{
QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration);
}
@@ -2066,6 +2073,7 @@ void QSslSocketPrivate::init()
ignoreAllSslErrors = false;
shutdown = false;
pendingClose = false;
+ flushTriggered = false;
// we don't want to clear the ignoreErrorsList, so
// that it is possible setting it before connecting
@@ -2249,6 +2257,7 @@ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPri
ptr->peerVerifyDepth = global->peerVerifyDepth;
ptr->sslOptions = global->sslOptions;
ptr->ellipticCurves = global->ellipticCurves;
+ ptr->backendConfig = global->backendConfig;
}
/*!
@@ -2534,6 +2543,10 @@ void QSslSocketPrivate::_q_readChannelFinishedSlot()
void QSslSocketPrivate::_q_flushWriteBuffer()
{
Q_Q(QSslSocket);
+
+ // need to notice if knock-on effects of this flush (e.g. a readReady() via transmit())
+ // make another necessary, so clear flag before calling:
+ flushTriggered = false;
if (!writeBuffer.isEmpty())
q->flush();
}
@@ -2648,6 +2661,20 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize)
/*!
\internal
*/
+qint64 QSslSocketPrivate::skip(qint64 maxSize)
+{
+ if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake)
+ return plainSocket->skip(maxSize);
+
+ // In encrypted mode, the SSL backend writes decrypted data directly into the
+ // QIODevice's read buffer. As this buffer is always emptied by the caller,
+ // we need to wait for more incoming data.
+ return (state == QAbstractSocket::ConnectedState) ? Q_INT64_C(0) : Q_INT64_C(-1);
+}
+
+/*!
+ \internal
+*/
bool QSslSocketPrivate::flush()
{
#ifdef QSSLSOCKET_DEBUG