From 13401116cce64bc7f2cf80b07ce34a4ad3abe829 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 6 Sep 2014 13:07:37 +0300 Subject: Remove incorrect read from QSslSocket::readData() QIODevice makes readData() call only when its read buffer is empty. Also data argument points to the user or reserved read buffer area. So, no need in data transfer from read buffer at this point at all. Task-number: QTBUG-41797 Change-Id: Ieb4afdf7eec37fdf288073e4a060e64424f22b9c Reviewed-by: Thiago Macieira (cherry picked from commit 1853579dad1bbb44599314213a1d8a203ecae1c9) Reviewed-by: Alex Trotsenko Reviewed-by: Oswald Buddenhagen --- src/network/ssl/qsslsocket.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/network') diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 27b085ddbd..8887f478dd 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1908,18 +1908,14 @@ qint64 QSslSocket::readData(char *data, qint64 maxlen) if (d->mode == UnencryptedMode && !d->autoStartHandshake) { readBytes = d->plainSocket->read(data, maxlen); - } else { - int bytesToRead = qMin(maxlen, d->buffer.size()); - readBytes = d->buffer.read(data, bytesToRead); - } - #ifdef QSSLSOCKET_DEBUG - qDebug() << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") ==" << readBytes; + qDebug() << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") ==" + << readBytes; #endif - - // possibly trigger another transmit() to decrypt more data from the socket - if (d->buffer.isEmpty() && d->plainSocket->bytesAvailable()) { - QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection); + } else { + // possibly trigger another transmit() to decrypt more data from the socket + if (d->plainSocket->bytesAvailable()) + QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection); } return readBytes; -- cgit v1.2.3