summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2013-04-09 16:25:00 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-16 06:01:42 (GMT)
commit11bac1e6f7b7a0d8be25554dc08917fa1b00d4f8 (patch)
tree7d652713b8f66f68d9ea3a179a7a4b372d3ac2fd /src
parent522c899b777eb25adb7e235baf0027c0c0a9119a (diff)
downloadQt-11bac1e6f7b7a0d8be25554dc08917fa1b00d4f8.zip
Qt-11bac1e6f7b7a0d8be25554dc08917fa1b00d4f8.tar.gz
Qt-11bac1e6f7b7a0d8be25554dc08917fa1b00d4f8.tar.bz2
QNetworkConfigurationManager: check whether app is shutting down
... before trying to update the configurations. Before, we would check whether the pointer to the QNetworkConfigurationManagerPrivate instance was 0 and in that case construct it. This would mean that this code path was taken "at app shutdown", i.e. when the qAddPostRoutine had already been called but the other statics were still accessed. Note: This is not thread safe, but neither is the rest of the code; making it thread-safe would require additional changes. Task-number: QTBUG-30585 (backport of commit cc028650e590ac49293558099b3fb87720e9793b) Change-Id: Ifaae4d758a10b44bc7f838cdc0d3a1129ed63228 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 20f5c81..d0bb054 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -56,10 +56,13 @@ QT_BEGIN_NAMESPACE
static QBasicAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
Q_GLOBAL_STATIC(QMutex, connManager_mutex)
+static QBasicAtomicInt appShutdown;
static void connManager_cleanup()
{
// this is not atomic or thread-safe!
+ int shutdown = appShutdown.fetchAndStoreAcquire(1);
+ Q_ASSERT(shutdown == 0);
if(connManager_ptr)
connManager_ptr->cleanup();
connManager_ptr = 0;
@@ -73,7 +76,7 @@ void QNetworkConfigurationManagerPrivate::addPostRoutine()
static QNetworkConfigurationManagerPrivate *connManager()
{
QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.fetchAndAddAcquire(0);
- if (!ptr) {
+ if (!ptr && !appShutdown) {
QMutexLocker locker(connManager_mutex());
if (!(ptr = connManager_ptr.fetchAndAddAcquire(0))) {
ptr = new QNetworkConfigurationManagerPrivate;