diff options
author | David Faure <david.faure@kdab.com> | 2013-03-18 15:19:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-22 16:44:51 +0100 |
commit | f4609b202208fe592d24c7ae3b4a48ee83045497 (patch) | |
tree | c9827efe74688595664c379085ba2a6267e49c13 /src/network/socket/qabstractsocket.cpp | |
parent | 85b25fc22176b574865813fa53f7eb2fcbdc89bf (diff) |
QThread: fix race when setting the eventDispatcher
Use QAtomicPointer to make this thread-safe.
Change-Id: If71f204699fcefabdb59bd26342d777d1cc9e2a7
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index c19238d768..71d6166840 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -643,7 +643,7 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc return false; } - if (threadData->eventDispatcher) + if (threadData->hasEventDispatcher()) socketEngine->setReceiver(this); #if defined (QABSTRACTSOCKET_DEBUG) @@ -1134,7 +1134,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() } // Start the connect timer. - if (threadData->eventDispatcher) { + if (threadData->hasEventDispatcher()) { if (!connectTimer) { connectTimer = new QTimer(q); QObject::connect(connectTimer, SIGNAL(timeout()), @@ -1159,7 +1159,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() void QAbstractSocketPrivate::_q_testConnection() { if (socketEngine) { - if (threadData->eventDispatcher) { + if (threadData->hasEventDispatcher()) { if (connectTimer) connectTimer->stop(); } @@ -1180,7 +1180,7 @@ void QAbstractSocketPrivate::_q_testConnection() addresses.clear(); } - if (threadData->eventDispatcher) { + if (threadData->hasEventDispatcher()) { if (connectTimer) connectTimer->stop(); } @@ -1640,7 +1640,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, return; #endif } else { - if (d->threadData->eventDispatcher) { + if (d->threadData->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; @@ -1846,7 +1846,7 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState return false; } - if (d->threadData->eventDispatcher) + if (d->threadData->hasEventDispatcher()) d->socketEngine->setReceiver(d); QIODevice::open(openMode); |