summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/nativewifi/main.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-08-24 09:47:55 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-29 14:15:58 +0200
commite8963749a7ffec3096478a4104a08bff4aaf3742 (patch)
tree5470bf3d5f42b33af7282a7b12df45b6e5725c44 /src/plugins/bearer/nativewifi/main.cpp
parentb2edd830b1493ac7fb03a89ce6975769e2a3cbda (diff)
QNativeWifiEnginePlugin: replace a volatile bool with an atomic int
Since there is non-atomic data that is protected by 'triedResolve', the (outer) read from triedResolve needs to have acquire, and the store needs to have release semantics. The release implied by the mutex unlock is not good enough because it only synchronises-with the locking of the same mutex, which not all threads execute. Change-Id: I90b62c4c0213472ecf2b95a1674a1c6c79dc3786 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/plugins/bearer/nativewifi/main.cpp')
-rw-r--r--src/plugins/bearer/nativewifi/main.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp
index a1ecd22d07..e431e82c79 100644
--- a/src/plugins/bearer/nativewifi/main.cpp
+++ b/src/plugins/bearer/nativewifi/main.cpp
@@ -56,14 +56,14 @@ QT_BEGIN_NAMESPACE
static void resolveLibrary()
{
- static volatile bool triedResolve = false;
+ static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false);
- if (!triedResolve) {
+ if (!triedResolve.loadAcquire()) {
#ifndef QT_NO_THREAD
QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle));
#endif
- if (!triedResolve) {
+ if (!triedResolve.load()) {
local_WlanOpenHandle = (WlanOpenHandleProto)
QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle");
local_WlanRegisterNotification = (WlanRegisterNotificationProto)
@@ -85,7 +85,7 @@ static void resolveLibrary()
local_WlanCloseHandle = (WlanCloseHandleProto)
QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle");
- triedResolve = true;
+ triedResolve.storeRelease(true);
}
}
}