diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2016-01-08 12:48:50 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2016-01-15 18:24:13 +0000 |
commit | 982656351be2f4ec84803022f5ce92f3755a44ad (patch) | |
tree | 6564f3156531f4a669118659a6189ae318ccdf42 /src | |
parent | e666ce162b75e926d8746177a30e38d124767e3d (diff) | |
download | qtbase-982656351be2f4ec84803022f5ce92f3755a44ad.tar.gz |
QAbstractSocket: remove redundant handling of recursive calls
Recursion is alredy prevented by the emittedReadyRead member.
Disabling the read notifications also occurs when:
- a new chunk of data has arrived on an unbuffered socket;
- the buffer size limit has been reached on a buffered socket;
- pauseSocketNotifiers() has been called
Subsequent calls to read() or resumeSocketNotifiers() should re-enable
the notifications independently from possible nesting.
Change-Id: I4587265b8d3ed137516e08fbe92dce2f5eab508c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 25 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket_p.h | 4 |
2 files changed, 2 insertions, 27 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 974659d971..ae12371258 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -549,10 +549,7 @@ static bool isProxyError(QAbstractSocket::SocketError error) Constructs a QAbstractSocketPrivate. Initializes all members. */ QAbstractSocketPrivate::QAbstractSocketPrivate() - : readSocketNotifierCalled(false), - readSocketNotifierState(false), - readSocketNotifierStateSet(false), - emittedReadyRead(false), + : emittedReadyRead(false), emittedBytesWritten(false), abortCalled(false), pendingClose(false), @@ -684,17 +681,6 @@ bool QAbstractSocketPrivate::canReadNotification() qDebug("QAbstractSocketPrivate::canReadNotification()"); #endif - // Prevent recursive calls - if (readSocketNotifierCalled) { - if (!readSocketNotifierStateSet) { - readSocketNotifierStateSet = true; - readSocketNotifierState = socketEngine->isReadNotificationEnabled(); - socketEngine->setReadNotificationEnabled(false); - } - } - QScopedValueRollback<bool> rsncrollback(readSocketNotifierCalled); - readSocketNotifierCalled = true; - if (!isBuffered) socketEngine->setReadNotificationEnabled(false); @@ -744,13 +730,6 @@ bool QAbstractSocketPrivate::canReadNotification() if (socketEngine && isBuffered) socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable()); - // reset the read socket notifier state if we reentered inside the - // readyRead() connected slot. - if (readSocketNotifierStateSet && socketEngine && - readSocketNotifierState != socketEngine->isReadNotificationEnabled()) { - socketEngine->setReadNotificationEnabled(readSocketNotifierState); - readSocketNotifierStateSet = false; - } return true; } @@ -2819,7 +2798,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size) if (d->readBufferMaxSize == size) return; d->readBufferMaxSize = size; - if (!d->readSocketNotifierCalled && d->socketEngine) { + if (!d->emittedReadyRead && d->socketEngine) { // ensure that the read notification is enabled if we've now got // room in the read buffer // but only if we're not inside canReadNotification -- that will take care on its own diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 89de5f2684..7b911b450e 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -97,10 +97,6 @@ public: void _q_abortConnectionAttempt(); void _q_forceDisconnect(); - bool readSocketNotifierCalled; - bool readSocketNotifierState; - bool readSocketNotifierStateSet; - bool emittedReadyRead; bool emittedBytesWritten; |