From 66008040793f7e98f9cacd13271119b6b096d8bc Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 6 Sep 2014 13:07:37 +0300 Subject: [PATCH] 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. Change-Id: Ieb4afdf7eec37fdf288073e4a060e64424f22b9c Reviewed-by: Thiago Macieira --- src/network/ssl/qsslsocket.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index d584c28e15..91d88e49f7 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1916,18 +1916,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;