diff options
author | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-08-22 11:30:00 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-08-22 11:30:01 +0200 |
commit | d314819fc02139e05e16c56657898c704f7fb48f (patch) | |
tree | a61ba968233634948401c8339f9613844de1c2b5 /src/network/socket | |
parent | 9f888d2fde9c5413e5519e0914e9b13638760985 (diff) | |
parent | e0e9e196a72ffe5457034894eaaadc90ed0d34ef (diff) |
Merge dev into 5.8
Change-Id: I41ee7b50534b01cf042bed8bb8824ba2e5026a29
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 43 | ||||
-rw-r--r-- | src/network/socket/qlocalserver.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qlocalsocket_tcp.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/socket.pri | 4 |
5 files changed, 26 insertions, 27 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index be60d187ad..87ef31fb22 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. */ @@ -693,19 +693,12 @@ bool QAbstractSocketPrivate::canReadNotification() qDebug("QAbstractSocketPrivate::canReadNotification()"); #endif - if (!isBuffered) { - if (hasPendingData) { - socketEngine->setReadNotificationEnabled(false); - return true; - } - hasPendingData = true; - } - // 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 +708,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,21 +715,28 @@ 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(); + } + } else { + if (hasPendingData) { + socketEngine->setReadNotificationEnabled(false); + return true; + } + hasPendingData = true; } - // 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. - if (state == QAbstractSocket::UnconnectedState || state == QAbstractSocket::ClosingState) { #if defined (QABSTRACTSOCKET_DEBUG) + // If we were closed as a result of the readyRead() signal. + if (state == QAbstractSocket::UnconnectedState || state == QAbstractSocket::ClosingState) qDebug("QAbstractSocketPrivate::canReadNotification() socket is closing - returning"); #endif - return true; - } return true; } diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index a1085f726a..94143c2dc0 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -147,7 +147,7 @@ QLocalServer::~QLocalServer() and are created based on the umask. Setting the access flags will overide this and will restrict or permit access as specified. - Other Unix-based operating systems, such as OS X, do not + Other Unix-based operating systems, such as \macos, do not honor file permissions for Unix domain sockets and by default have WorldAccess and these permission flags will have no effect. diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 4348b819d9..379cdd096d 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -245,8 +245,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) QLatin1String("QLocalSocket::connectToServer")); return; } - d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); QIODevice::open(openMode); + d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); } bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index d7d7dad8e7..d1efc21e09 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -317,7 +317,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co case QNativeSocketEngine::BindExclusively: case QNativeSocketEngine::NonBlockingSocketOption: case QNativeSocketEngine::BroadcastSocketOption: - return true; + return -1; case QNativeSocketEngine::MaxStreamsSocketOption: { #ifndef QT_NO_SCTP sctp_initmsg sctpInitMsg; diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index b1c0b6bd6e..793ea60b07 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -27,7 +27,7 @@ SOURCES += socket/qabstractsocketengine.cpp \ # SCTP support. -contains(QT_CONFIG, sctp) { +qtConfig(sctp) { HEADERS += socket/qsctpserver.h \ socket/qsctpserver_p.h \ socket/qsctpsocket.h \ @@ -80,6 +80,6 @@ integrity: { DEFINES += QT_LOCALSOCKET_TCP } -contains(QT_CONFIG, system-proxies) { +qtConfig(system-proxies) { DEFINES += QT_USE_SYSTEM_PROXIES } |