diff options
author | Thiago Macieira <thiago@kde.org> | 2011-07-06 00:06:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-06 22:45:14 +0200 |
commit | 028a860ac58bc6b956e523e04f9dfdda032cad81 (patch) | |
tree | 26e1d3020832717e37b1a0fe341472c2158ff29a /src/network/bearer/qnetworkconfigmanager_p.h | |
parent | 8fb15f3a7540b0ef40ee15292e76a442889fed36 (diff) |
Fix the QNetworkConnectionManagerPrivate initialisation code.
The current code was meant to be a thread-safe initialisation that
also ran a couple of extra steps. But it wasn't. While it's ok to call
qAddPostRoutine(), the call to updateConfigurations() was
thread-unsafe. It is possible that another thread got the pointer to
the Private before updateConfigurations() finished.
So instead protect the initialisation with a mutex.
It's possible that the value of the pointer becomes visible to
other processors before the other contained values, so use
atomics here.
To call qAddPostRoutine safely from the main thread, use the trick
of deleteLater() (which is thread-safe) in another thread connecting
to a slot.
Change-Id: If9bab88138755df95a791f34b0be8684207979d7
Reviewed-on: http://codereview.qt-project.org/5028
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/network/bearer/qnetworkconfigmanager_p.h')
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 04cce202c5..e73e9bb399 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -92,6 +92,8 @@ public: public Q_SLOTS: void updateConfigurations(); + static void addPostRoutine(); + Q_SIGNALS: void configurationAdded(const QNetworkConfiguration &config); void configurationRemoved(const QNetworkConfiguration &config); @@ -106,6 +108,7 @@ private Q_SLOTS: void pollEngines(); + private: Q_INVOKABLE void startPolling(); QTimer *pollTimer; |