diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-10-06 14:40:34 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-10-06 16:13:26 (GMT) |
commit | 7e662f3727e7c3dd3c41c29ed49bc41d2b66c744 (patch) | |
tree | b317cd719656cb7d2dca1ea0128b4a4a63ded90a /src/network/bearer | |
parent | 51ed77637a6001f66805e8091ce8616d8f2530db (diff) | |
download | Qt-7e662f3727e7c3dd3c41c29ed49bc41d2b66c744.zip Qt-7e662f3727e7c3dd3c41c29ed49bc41d2b66c744.tar.gz Qt-7e662f3727e7c3dd3c41c29ed49bc41d2b66c744.tar.bz2 |
Fix construction races in QtNetwork
When two threads construct a QNetworkAccessManager at exactly the
same time on an SMP system, there are construction races for some
Q_GLOBAL_STATIC data. This is normal and expected - the losing
thread deletes its instance as part of the Q_GLOBAL_STATIC macro.
However, for two of the classes, destruction of the loser had
side effects. For QNetworkConfigurationMangerPrivate, there was
a crash because of uninitialised variable on the losing side.
For QNetworkAccessBackendFactoryData, a guard mechanism intended
to prevent the data being reconstructed by destructors of other
global static classes was being set by the loser.
To fix this, the bool is changed to a QAtomicInt. In the normal
case, it will have value 0->1 on startup and 1->0 on shutdown.
In the race case, it will have values 0->1->2->1 on startup and
1->0 on shutdown.
Task-Number: QTBUG-20343
Reviewed-By: mread
Diffstat (limited to 'src/network/bearer')
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 18e29af..96a534d 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, #endif QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) + : QObject(), pollTimer(0), bearerThread(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer"); |