summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qabstractsocket.cpp75
-rw-r--r--src/network/socket/qabstractsocket.h7
-rw-r--r--src/network/socket/qabstractsocketengine.cpp6
-rw-r--r--src/network/socket/qhttpsocketengine.cpp29
-rw-r--r--src/network/socket/qlocalserver.cpp2
-rw-r--r--src/network/socket/qlocalserver_unix.cpp2
-rw-r--r--src/network/socket/qlocalsocket.cpp35
-rw-r--r--src/network/socket/qlocalsocket.h7
-rw-r--r--src/network/socket/qlocalsocket_tcp.cpp7
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp22
-rw-r--r--src/network/socket/qlocalsocket_win.cpp7
-rw-r--r--src/network/socket/qnativesocketengine.cpp18
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp6
-rw-r--r--src/network/socket/qsocks5socketengine.cpp50
-rw-r--r--src/network/socket/qtcpserver.cpp6
15 files changed, 168 insertions, 111 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 9c8f29e18a..b8957ce818 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -215,7 +215,7 @@
connections, you will have to register it with Q_DECLARE_METATYPE() and
qRegisterMetaType().
- \sa error(), errorString(), {Creating Custom Qt Types}
+ \sa socketError(), errorString(), {Creating Custom Qt Types}
*/
/*!
@@ -329,7 +329,7 @@
is non-blocking).
\value UnknownSocketError An unidentified error occurred.
- \sa QAbstractSocket::error()
+ \sa QAbstractSocket::socketError()
*/
/*!
@@ -564,12 +564,12 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
port(0),
localPort(0),
peerPort(0),
- socketEngine(0),
+ socketEngine(nullptr),
cachedSocketDescriptor(-1),
readBufferMaxSize(0),
isBuffered(false),
hasPendingData(false),
- connectTimer(0),
+ connectTimer(nullptr),
hostLookupId(-1),
socketType(QAbstractSocket::UnknownSocketType),
state(QAbstractSocket::UnconnectedState),
@@ -603,7 +603,7 @@ void QAbstractSocketPrivate::resetSocketLayer()
socketEngine->close();
socketEngine->disconnect();
delete socketEngine;
- socketEngine = 0;
+ socketEngine = nullptr;
cachedSocketDescriptor = -1;
}
if (connectTimer)
@@ -659,7 +659,7 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
configureCreatedSocket();
- if (threadData->hasEventDispatcher())
+ if (threadData.loadRelaxed()->hasEventDispatcher())
socketEngine->setReceiver(this);
#if defined (QABSTRACTSOCKET_DEBUG)
@@ -1138,7 +1138,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
}
// Start the connect timer.
- if (threadData->hasEventDispatcher()) {
+ if (threadData.loadRelaxed()->hasEventDispatcher()) {
if (!connectTimer) {
connectTimer = new QTimer(q);
QObject::connect(connectTimer, SIGNAL(timeout()),
@@ -1740,7 +1740,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
return;
#endif
} else {
- if (d->threadData->hasEventDispatcher()) {
+ if (d->threadData.loadRelaxed()->hasEventDispatcher()) {
// this internal API for QHostInfo either immediately gives us the desired
// QHostInfo from cache or later calls the _q_startConnecting slot.
bool immediateResultValid = false;
@@ -1953,7 +1953,7 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState
// Sync up with error string, which open() shall clear.
d->socketError = UnknownSocketError;
- if (d->threadData->hasEventDispatcher())
+ if (d->threadData.loadRelaxed()->hasEventDispatcher())
d->socketEngine->setReceiver(d);
QIODevice::open(openMode);
@@ -2094,7 +2094,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
Waits until the socket is connected, up to \a msecs
milliseconds. If the connection has been established, this
function returns \c true; otherwise it returns \c false. In the case
- where it returns \c false, you can call error() to determine
+ where it returns \c false, you can call socketError() to determine
the cause of the error.
The following example waits up to one second for a connection
@@ -2144,20 +2144,13 @@ bool QAbstractSocket::waitForConnected(int msecs)
#endif
QHostInfo::abortHostLookup(d->hostLookupId);
d->hostLookupId = -1;
-#ifndef QT_NO_BEARERMANAGEMENT
- if (networkSession) {
- d->_q_startConnecting(QHostInfoPrivate::fromName(d->hostName, networkSession));
- } else
-#endif
- {
- QHostAddress temp;
- if (temp.setAddress(d->hostName)) {
- QHostInfo info;
- info.setAddresses(QList<QHostAddress>() << temp);
- d->_q_startConnecting(info);
- } else {
- d->_q_startConnecting(QHostInfo::fromName(d->hostName));
- }
+ QHostAddress temp;
+ if (temp.setAddress(d->hostName)) {
+ QHostInfo info;
+ info.setAddresses(QList<QHostAddress>() << temp);
+ d->_q_startConnecting(info);
+ } else {
+ d->_q_startConnecting(QHostInfo::fromName(d->hostName));
}
}
if (state() == UnconnectedState)
@@ -2359,11 +2352,12 @@ bool QAbstractSocket::waitForBytesWritten(int msecs)
}
/*!
- Waits until the socket has disconnected, up to \a msecs
- milliseconds. If the connection has been disconnected, this
- function returns \c true; otherwise it returns \c false. In the case
- where it returns \c false, you can call error() to determine
- the cause of the error.
+ Waits until the socket has disconnected, up to \a msecs milliseconds. If the
+ connection was successfully disconnected, this function returns \c true;
+ otherwise it returns \c false (if the operation timed out, if an error
+ occurred, or if this QAbstractSocket is already disconnected). In the case
+ where it returns \c false, you can call error() to determine the cause of
+ the error.
The following example waits up to one second for a connection
to be closed:
@@ -2872,7 +2866,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
/*!
Returns the state of the socket.
- \sa error()
+ \sa socketError()
*/
QAbstractSocket::SocketState QAbstractSocket::state() const
{
@@ -2899,16 +2893,35 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const
return d_func()->socketType;
}
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
+ \deprecated
+
+ Use socketError() instead.
+
Returns the type of error that last occurred.
- \sa state(), errorString()
+ \sa state(), errorString(), socketError()
*/
QAbstractSocket::SocketError QAbstractSocket::error() const
{
+ return socketError();
+}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+
+ Returns the type of error that last occurred.
+
+ \sa state(), errorString()
+*/
+QAbstractSocket::SocketError QAbstractSocket::socketError() const
+{
return d_func()->socketError;
}
+
/*!
Sets the type of error that last occurred to \a socketError.
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index de09195eeb..cbc79ea684 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -180,7 +180,12 @@ public:
SocketType socketType() const;
SocketState state() const;
- SocketError error() const;
+
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use socketError()") SocketError error() const;
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+ SocketError socketError() const;
// from QIODevice
void close() override;
diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp
index db3a8280bd..44139ff81d 100644
--- a/src/network/socket/qabstractsocketengine.cpp
+++ b/src/network/socket/qabstractsocketengine.cpp
@@ -85,7 +85,7 @@ QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate()
, peerPort(0)
, inboundStreamCount(0)
, outboundStreamCount(0)
- , receiver(0)
+ , receiver(nullptr)
{
}
@@ -104,7 +104,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket
#ifndef QT_NO_NETWORKPROXY
// proxy type must have been resolved by now
if (proxy.type() == QNetworkProxy::DefaultProxy)
- return 0;
+ return nullptr;
#endif
QMutexLocker locker(&socketHandlers()->mutex);
@@ -116,7 +116,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket
#ifndef QT_NO_NETWORKPROXY
// only NoProxy can have reached here
if (proxy.type() != QNetworkProxy::NoProxy)
- return 0;
+ return nullptr;
#endif
return new QNativeSocketEngine(parent);
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index 2244955c55..98f850ba1b 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -216,7 +216,7 @@ void QHttpSocketEngine::close()
if (d->socket) {
d->socket->close();
delete d->socket;
- d->socket = 0;
+ d->socket = nullptr;
}
}
@@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
if (d->socket->state() == QAbstractSocket::UnconnectedState)
return true;
- setError(d->socket->error(), d->socket->errorString());
- if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
+ setError(d->socket->socketError(), d->socket->errorString());
+ if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
return false;
}
@@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut)
// Report any error that may occur.
if (d->state != Connected) {
- setError(d->socket->error(), d->socket->errorString());
- if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
+ setError(d->socket->socketError(), d->socket->errorString());
+ if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
return false;
}
@@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
if (d->state == Connected) {
if (d->socket->bytesToWrite()) {
if (!d->socket->waitForBytesWritten(msecs)) {
- if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut)
+ if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut)
*timedOut = true;
return false;
}
@@ -421,8 +421,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut)
// Report any error that may occur.
if (d->state != Connected) {
-// setError(d->socket->error(), d->socket->errorString());
- if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError)
+ if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
}
@@ -586,7 +585,7 @@ void QHttpSocketEngine::slotSocketReadNotification()
}
int statusCode = d->reply->statusCode();
- QAuthenticatorPrivate *priv = 0;
+ QAuthenticatorPrivate *priv = nullptr;
if (statusCode == 200) {
d->state = Connected;
setLocalAddress(d->socket->localAddress());
@@ -829,8 +828,8 @@ QHttpSocketEnginePrivate::QHttpSocketEnginePrivate()
, credentialsSent(false)
, pendingResponseData(0)
{
- socket = 0;
- reply = 0;
+ socket = nullptr;
+ reply = nullptr;
state = QHttpSocketEngine::None;
}
@@ -843,15 +842,15 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc
QObject *parent)
{
if (socketType != QAbstractSocket::TcpSocket)
- return 0;
+ return nullptr;
// proxy type must have been resolved by now
if (proxy.type() != QNetworkProxy::HttpProxy)
- return 0;
+ return nullptr;
// we only accept active sockets
if (!qobject_cast<QAbstractSocket *>(parent))
- return 0;
+ return nullptr;
QHttpSocketEngine *engine = new QHttpSocketEngine(parent);
engine->setProxy(proxy);
@@ -860,7 +859,7 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc
QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(qintptr, QObject *)
{
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index 3e36a7b229..5ca2db70b9 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -417,7 +417,7 @@ QLocalSocket *QLocalServer::nextPendingConnection()
{
Q_D(QLocalServer);
if (d->pendingConnections.isEmpty())
- return 0;
+ return nullptr;
QLocalSocket *nextSocket = d->pendingConnections.dequeue();
#ifndef QT_LOCALSOCKET_TCP
if (d->pendingConnections.size() <= d->maxPendingConnections)
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index 9547ec5b88..88367d680d 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -243,7 +243,7 @@ void QLocalServerPrivate::closeServer()
if (socketNotifier) {
socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs
socketNotifier->deleteLater();
- socketNotifier = 0;
+ socketNotifier = nullptr;
}
if (-1 != listenSocket)
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index 1c34cd13ee..d517f91aad 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -220,11 +220,25 @@ QT_BEGIN_NAMESPACE
/*!
\fn QLocalSocket::LocalSocketError QLocalSocket::error() const
+ \deprecated
+
+ Use socketError() instead.
+
+ Returns the type of error that last occurred.
+
+ \sa state(), errorString(), socketError()
+*/
+
+/*!
+ \fn QLocalSocket::LocalSocketError QLocalSocket::socketError() const
+ \since 5.15
+
Returns the type of error that last occurred.
\sa state(), errorString()
*/
+
/*!
\fn bool QLocalSocket::isValid() const
@@ -272,7 +286,7 @@ QT_BEGIN_NAMESPACE
Waits until the socket is connected, up to \a msecs milliseconds. If the
connection has been established, this function returns \c true; otherwise
it returns \c false. In the case where it returns \c false, you can call
- error() to determine the cause of the error.
+ socketError() to determine the cause of the error.
The following example waits up to one second for a connection
to be established:
@@ -287,11 +301,12 @@ QT_BEGIN_NAMESPACE
/*!
\fn bool QLocalSocket::waitForDisconnected(int msecs)
- Waits until the socket has disconnected, up to \a msecs
- milliseconds. If the connection has been disconnected, this
- function returns \c true; otherwise it returns \c false. In the case
- where it returns \c false, you can call error() to determine
- the cause of the error.
+ Waits until the socket has disconnected, up to \a msecs milliseconds. If the
+ connection was successfully disconnected, this function returns \c true;
+ otherwise it returns \c false (if the operation timed out, if an error
+ occurred, or if this QLocalSocket is already disconnected). In the case
+ where it returns \c false, you can call socketError() to determine the cause of
+ the error.
The following example waits up to one second for a connection
to be closed:
@@ -336,7 +351,7 @@ QT_BEGIN_NAMESPACE
connections, you will have to register it with Q_DECLARE_METATYPE() and
qRegisterMetaType().
- \sa error(), errorString(), {Creating Custom Qt Types}
+ \sa socketError(), errorString(), {Creating Custom Qt Types}
*/
/*!
@@ -371,7 +386,7 @@ QLocalSocket::~QLocalSocket()
QLocalSocket::close();
#if !defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP)
Q_D(QLocalSocket);
- d->unixSocket.setParent(0);
+ d->unixSocket.setParent(nullptr);
#endif
}
@@ -445,7 +460,7 @@ QString QLocalSocket::fullServerName() const
/*!
Returns the state of the socket.
- \sa error()
+ \sa socketError()
*/
QLocalSocket::LocalSocketState QLocalSocket::state() const
{
@@ -465,7 +480,7 @@ bool QLocalSocket::isSequential() const
The LocalServerError enumeration represents the errors that can occur.
The most recent error can be retrieved through a call to
- \l QLocalSocket::error().
+ \l QLocalSocket::socketError().
\value ConnectionRefusedError The connection was refused by
the peer (or timed out).
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index 1876a6ac0d..9cf76d1022 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -97,7 +97,12 @@ public:
virtual bool canReadLine() const override;
virtual bool open(OpenMode openMode = ReadWrite) override;
virtual void close() override;
- LocalSocketError error() const;
+
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use socketError()") LocalSocketError error() const;
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+ LocalSocketError socketError() const;
bool flush();
bool isValid() const;
qint64 readBufferSize() const;
diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp
index 41e5b47627..74d3d547b9 100644
--- a/src/network/socket/qlocalsocket_tcp.cpp
+++ b/src/network/socket/qlocalsocket_tcp.cpp
@@ -363,8 +363,15 @@ void QLocalSocket::disconnectFromServer()
d->tcpSocket->disconnectFromHost();
}
+#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const
{
+ return socketError();
+}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+QLocalSocket::LocalSocketError QLocalSocket::socketError() const
+{
Q_D(const QLocalSocket);
switch (d->tcpSocket->error()) {
case QAbstractSocket::ConnectionRefusedError:
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index d1df26d9f1..2e2eb7dee9 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -61,10 +61,9 @@
QT_BEGIN_NAMESPACE
QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
- delayConnect(0),
- connectTimer(0),
+ delayConnect(nullptr),
+ connectTimer(nullptr),
connectingSocket(-1),
- connectingOpenMode(0),
state(QLocalSocket::UnconnectedState)
{
}
@@ -341,7 +340,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
}
connectingSocket = -1;
connectingName.clear();
- connectingOpenMode = 0;
+ connectingOpenMode = { };
}
bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
@@ -380,10 +379,10 @@ void QLocalSocketPrivate::cancelDelayedConnect()
if (delayConnect) {
delayConnect->setEnabled(false);
delete delayConnect;
- delayConnect = 0;
+ delayConnect = nullptr;
connectTimer->stop();
delete connectTimer;
- connectTimer = 0;
+ connectTimer = nullptr;
}
}
@@ -438,7 +437,7 @@ void QLocalSocket::close()
::close(d->connectingSocket);
d->connectingSocket = -1;
d->connectingName.clear();
- d->connectingOpenMode = 0;
+ d->connectingOpenMode = { };
d->serverName.clear();
d->fullServerName.clear();
QIODevice::close();
@@ -462,10 +461,17 @@ void QLocalSocket::disconnectFromServer()
d->unixSocket.disconnectFromHost();
}
+#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const
{
+ return socketError();
+}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+QLocalSocket::LocalSocketError QLocalSocket::socketError() const
+{
Q_D(const QLocalSocket);
- switch (d->unixSocket.error()) {
+ switch (d->unixSocket.socketError()) {
case QAbstractSocket::ConnectionRefusedError:
return QLocalSocket::ConnectionRefusedError;
case QAbstractSocket::RemoteHostClosedError:
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 4decbd5ded..657790519b 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -330,8 +330,15 @@ void QLocalSocket::disconnectFromServer()
}
}
+#if QT_DEPRECATED_SINCE(5, 15)
QLocalSocket::LocalSocketError QLocalSocket::error() const
{
+ return socketError();
+}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+QLocalSocket::LocalSocketError QLocalSocket::socketError() const
+{
Q_D(const QLocalSocket);
return d->error;
}
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 7085fe3bbd..ad625b758e 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -191,9 +191,9 @@ QT_BEGIN_NAMESPACE
*/
QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() :
socketDescriptor(-1),
- readNotifier(0),
- writeNotifier(0),
- exceptNotifier(0)
+ readNotifier(nullptr),
+ writeNotifier(nullptr),
+ exceptNotifier(nullptr)
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QSysInfo::machineHostName(); // this initializes ws2_32.dll
@@ -985,15 +985,15 @@ void QNativeSocketEngine::close()
d->inboundStreamCount = d->outboundStreamCount = 0;
if (d->readNotifier) {
qDeleteInEventHandler(d->readNotifier);
- d->readNotifier = 0;
+ d->readNotifier = nullptr;
}
if (d->writeNotifier) {
qDeleteInEventHandler(d->writeNotifier);
- d->writeNotifier = 0;
+ d->writeNotifier = nullptr;
}
if (d->exceptNotifier) {
qDeleteInEventHandler(d->exceptNotifier);
- d->exceptNotifier = 0;
+ d->exceptNotifier = nullptr;
}
}
@@ -1341,7 +1341,7 @@ void QNativeSocketEngine::setReadNotificationEnabled(bool enable)
Q_D(QNativeSocketEngine);
if (d->readNotifier) {
d->readNotifier->setEnabled(enable);
- } else if (enable && d->threadData->hasEventDispatcher()) {
+ } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) {
d->readNotifier = new QReadNotifier(d->socketDescriptor, this);
d->readNotifier->setEnabled(true);
}
@@ -1358,7 +1358,7 @@ void QNativeSocketEngine::setWriteNotificationEnabled(bool enable)
Q_D(QNativeSocketEngine);
if (d->writeNotifier) {
d->writeNotifier->setEnabled(enable);
- } else if (enable && d->threadData->hasEventDispatcher()) {
+ } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) {
d->writeNotifier = new QWriteNotifier(d->socketDescriptor, this);
d->writeNotifier->setEnabled(true);
}
@@ -1375,7 +1375,7 @@ void QNativeSocketEngine::setExceptionNotificationEnabled(bool enable)
Q_D(QNativeSocketEngine);
if (d->exceptNotifier) {
d->exceptNotifier->setEnabled(enable);
- } else if (enable && d->threadData->hasEventDispatcher()) {
+ } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) {
d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this);
d->exceptNotifier->setEnabled(true);
}
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 3ca586e247..e5b9fbbdb2 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -628,7 +628,7 @@ bool QNativeSocketEnginePrivate::nativeListen(int backlog)
int QNativeSocketEnginePrivate::nativeAccept()
{
- int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
+ int acceptedDescriptor = qt_safe_accept(socketDescriptor, nullptr, nullptr);
if (acceptedDescriptor == -1) {
switch (errno) {
case EBADF:
@@ -1002,7 +1002,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
struct cmsghdr *cmsgptr;
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wsign-compare")
- for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL;
+ for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != nullptr;
cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
QT_WARNING_POP
if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_PKTINFO
@@ -1166,7 +1166,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
#endif
if (msg.msg_controllen == 0)
- msg.msg_control = 0;
+ msg.msg_control = nullptr;
ssize_t sentBytes = qt_safe_sendmsg(socketDescriptor, &msg, 0);
if (sentBytes < 0) {
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 4207832c4c..b2eefa352f 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -365,13 +365,13 @@ QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor)
QMutexLocker lock(&mutex);
const auto it = store.constFind(socketDescriptor);
if (it == store.cend())
- return 0;
+ return nullptr;
QSocks5BindData *bindData = it.value();
store.erase(it);
if (bindData) {
if (bindData->controlSocket->thread() != QThread::currentThread()) {
qWarning("Cannot access socks5 bind data from different thread");
- return 0;
+ return nullptr;
}
} else {
QSOCKS5_DEBUG << "__ERROR__ binddata == 0";
@@ -503,12 +503,12 @@ QSocks5SocketEnginePrivate::QSocks5SocketEnginePrivate()
, writeNotificationEnabled(false)
, exceptNotificationEnabled(false)
, socketDescriptor(-1)
- , data(0)
- , connectData(0)
+ , data(nullptr)
+ , connectData(nullptr)
#ifndef QT_NO_UDPSOCKET
- , udpData(0)
+ , udpData(nullptr)
#endif
- , bindData(0)
+ , bindData(nullptr)
, readNotificationActivated(false)
, writeNotificationActivated(false)
, readNotificationPending(false)
@@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString
case ConnectError:
case ControlSocketError: {
- QAbstractSocket::SocketError controlSocketError = data->controlSocket->error();
+ QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError();
if (socks5State != Connected) {
switch (controlSocketError) {
case QAbstractSocket::ConnectionRefusedError:
@@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification()
return;
// check if there needs to be a new zero read notification
if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState
- && data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) {
+ && data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) {
connectData->readBuffer.clear();
emitReadNotification();
}
@@ -1038,11 +1038,11 @@ bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::
d->data = d->connectData;
d->mode = QSocks5SocketEnginePrivate::ConnectMode;
d->data->controlSocket = bindData->controlSocket;
- bindData->controlSocket = 0;
+ bindData->controlSocket = nullptr;
d->data->controlSocket->setParent(this);
d->socketProtocol = d->data->controlSocket->localAddress().protocol();
d->data->authenticator = bindData->authenticator;
- bindData->authenticator = 0;
+ bindData->authenticator = nullptr;
d->localPort = bindData->localPort;
d->localAddress = bindData->localAddress;
d->peerPort = bindData->peerPort;
@@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr
data->controlSocket->close();
emitConnectionNotification();
} else {
- q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString());
+ q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString());
emitReadNotification();
emitWriteNotification();
}
@@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port)
if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) {
if (!d->udpData->udpSocket->bind(address, port)) {
QSOCKS5_Q_DEBUG << "local udp bind failed";
- setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
+ setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
return false;
}
d->localAddress = d->udpData->udpSocket->localAddress();
@@ -1367,7 +1367,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port)
QElapsedTimer stopWatch;
stopWatch.start();
d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port());
- if (!d->waitForConnected(msecs, 0) ||
+ if (!d->waitForConnected(msecs, nullptr) ||
d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) {
// waitForConnected sets the error state and closes the socket
QSOCKS5_Q_DEBUG << "waitForConnected to proxy server" << d->data->controlSocket->errorString();
@@ -1428,13 +1428,13 @@ int QSocks5SocketEngine::accept()
case QSocks5SocketEnginePrivate::BindSuccess:
QSOCKS5_Q_DEBUG << "BindSuccess adding" << d->socketDescriptor << "to the bind store";
d->data->controlSocket->disconnect();
- d->data->controlSocket->setParent(0);
+ d->data->controlSocket->setParent(nullptr);
d->bindData->localAddress = d->localAddress;
d->bindData->localPort = d->localPort;
sd = d->socketDescriptor;
socks5BindStore()->add(sd, d->bindData);
- d->data = 0;
- d->bindData = 0;
+ d->data = nullptr;
+ d->bindData = nullptr;
d->socketDescriptor = 0;
//### do something about this socket layer ... set it closed and an error about why ...
// reset state and local port/address
@@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
}
if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) {
//### try frgamenting
- if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError)
- setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
+ if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError)
+ setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
//### else maybe more serious error
return -1;
}
@@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut)
return true;
setErrorState(QSocks5SocketEnginePrivate::ControlSocketError);
- if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError)
+ if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
return false;
}
@@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState)
return true;
- setError(d->data->controlSocket->error(), d->data->controlSocket->errorString());
- if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError)
+ setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString());
+ if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
return false;
}
@@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut)
} else {
while (!d->readNotificationActivated) {
if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
- setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString());
- if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError)
+ setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString());
+ if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError)
*timedOut = true;
return false;
}
@@ -1909,7 +1909,7 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
// proxy type must have been resolved by now
if (proxy.type() != QNetworkProxy::Socks5Proxy) {
QSOCKS5_DEBUG << "not proxying";
- return 0;
+ return nullptr;
}
QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent));
engine->setProxy(proxy);
@@ -1923,7 +1923,7 @@ QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr so
QSOCKS5_DEBUG << "bind store contains" << socketDescriptor;
return new QSocks5SocketEngine(parent);
}
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 98e58192a2..9916c75e65 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -121,7 +121,7 @@ QTcpServerPrivate::QTcpServerPrivate()
: port(0)
, socketType(QAbstractSocket::UnknownSocketType)
, state(QAbstractSocket::UnconnectedState)
- , socketEngine(0)
+ , socketEngine(nullptr)
, serverSocketError(QAbstractSocket::UnknownSocketError)
, maxConnections(30)
{
@@ -389,7 +389,7 @@ void QTcpServer::close()
// in out of memory situations, the socketEngine
// will be deleted in ~QTcpServer (it's a child-object of this)
}
- d->socketEngine = 0;
+ d->socketEngine = nullptr;
}
d->state = QAbstractSocket::UnconnectedState;
@@ -561,7 +561,7 @@ QTcpSocket *QTcpServer::nextPendingConnection()
{
Q_D(QTcpServer);
if (d->pendingConnections.isEmpty())
- return 0;
+ return nullptr;
if (!d->socketEngine) {
qWarning("QTcpServer::nextPendingConnection() called while not listening");