diff options
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index be60d187ad..662c8e957e 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -428,7 +428,7 @@ allowed to rebind, even if they pass ReuseAddressHint. This option provides more security than ShareAddress, but on certain operating systems, it requires you to run the server with administrator privileges. - On Unix and OS X, not sharing is the default behavior for binding + On Unix and \macos, not sharing is the default behavior for binding an address and port, so this option is ignored. On Windows, this option uses the SO_EXCLUSIVEADDRUSE socket option. @@ -438,7 +438,7 @@ socket option. \value DefaultForPlatform The default option for the current platform. - On Unix and OS X, this is equivalent to (DontShareAddress + On Unix and \macos, this is equivalent to (DontShareAddress + ReuseAddressHint), and on Windows, its equivalent to ShareAddress. */ @@ -702,10 +702,11 @@ bool QAbstractSocketPrivate::canReadNotification() } // If buffered, read data from the socket into the read buffer - qint64 newBytes = 0; if (isBuffered) { + const qint64 oldBufferSize = buffer.size(); + // Return if there is no space in the buffer - if (readBufferMaxSize && buffer.size() >= readBufferMaxSize) { + if (readBufferMaxSize && oldBufferSize >= readBufferMaxSize) { socketEngine->setReadNotificationEnabled(false); #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::canReadNotification() buffer is full"); @@ -715,7 +716,6 @@ bool QAbstractSocketPrivate::canReadNotification() // If reading from the socket fails after getting a read // notification, close the socket. - newBytes = buffer.size(); if (!readFromSocket()) { #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::canReadNotification() disconnecting socket"); @@ -723,12 +723,16 @@ bool QAbstractSocketPrivate::canReadNotification() q->disconnectFromHost(); return false; } - newBytes = buffer.size() - newBytes; + + // Return if there is no new data available. + if (buffer.size() == oldBufferSize) { + // If the socket is opened only for writing, return true + // to indicate that the data was discarded. + return !q->isReadable(); + } } - // Only emit readyRead() if there is data available. - if (newBytes > 0 || !isBuffered) - emitReadyRead(); + emitReadyRead(); // If we were closed as a result of the readyRead() signal, // return. |