summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_win.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-06 20:21:09 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-05-06 22:20:08 +0000
commit857912b605ea11f6f1e782edfb40555d831eb9ad (patch)
tree49a4174a44e06ba55e9253e2e7f6f45fe1764c5c /src/network/kernel/qhostinfo_win.cpp
parent5aeafcea467ced35adca1d762d38bfbba2b59e1f (diff)
parentdbef41f43ece97d8ac4d6b63f7a36afcb7e7b7f7 (diff)
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'src/network/kernel/qhostinfo_win.cpp')
-rw-r--r--src/network/kernel/qhostinfo_win.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index cc6102a713..b98f36a612 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -45,7 +45,6 @@
#include <qmutex.h>
#include <qbasicatomic.h>
#include <qurl.h>
-#include <private/qmutexpool_p.h>
QT_BEGIN_NAMESPACE
@@ -78,7 +77,7 @@ static getnameinfoProto local_getnameinfo = 0;
static getaddrinfoProto local_getaddrinfo = 0;
static freeaddrinfoProto local_freeaddrinfo = 0;
-static void resolveLibrary()
+static bool resolveLibraryInternal()
{
// Attempt to resolve getaddrinfo(); without it we'll have to fall
// back to gethostbyname(), which has no IPv6 support.
@@ -95,7 +94,9 @@ static void resolveLibrary()
local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "freeaddrinfo");
local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getnameinfo");
#endif
+ return true;
}
+Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal()))
static void translateWSAError(int error, QHostInfo *results)
{
@@ -123,14 +124,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
QSysInfo::machineHostName(); // this initializes ws2_32.dll
// Load res_init on demand.
- static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false);
- if (!triedResolve.loadAcquire()) {
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo));
- if (!triedResolve.load()) {
- resolveLibrary();
- triedResolve.storeRelease(true);
- }
- }
+ resolveLibrary();
QHostInfo results;