summaryrefslogtreecommitdiffstats
path: root/src/network/bearer
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2013-04-09 18:25:00 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-10 13:27:01 +0200
commitf273d6fbc02055ff3999adc0df76360ca0670435 (patch)
tree7660117606d987a02951e03fb3875bf164f56c97 /src/network/bearer
parent0eefbf8376aa5517129536aab4a8fddc905df419 (diff)
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 Change-Id: I8f6cf616e3f3ba1e84b8246589fb7210d2dae57a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/network/bearer')
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 49d6babb10..4f74936ac7 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -55,10 +55,13 @@
QT_BEGIN_NAMESPACE
static QBasicAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
+static QBasicAtomicInt appShutdown;
static void connManager_cleanup()
{
// this is not atomic or thread-safe!
+ int shutdown = appShutdown.fetchAndStoreAcquire(1);
+ Q_ASSERT(shutdown == 0);
QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(0);
if (cmp)
cmp->cleanup();
@@ -72,7 +75,8 @@ void QNetworkConfigurationManagerPrivate::addPostRoutine()
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.loadAcquire();
- if (!ptr) {
+ int shutdown = appShutdown.loadAcquire();
+ if (!ptr && !shutdown) {
static QBasicMutex connManager_mutex;
QMutexLocker locker(&connManager_mutex);
if (!(ptr = connManager_ptr.loadAcquire())) {