summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qdnslookup_unix.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-12 07:31:50 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-12 08:33:08 +0200
commit990969655c5fb4d03682e96df9b12101f5ee9815 (patch)
treeb8fb5c50285105c8bc5a938fb50f93ff9f24889d /src/network/kernel/qdnslookup_unix.cpp
parenta213011a53f12f101d08a04afc8fdacd2d54a232 (diff)
parente64b2234e829cc47872225debcf80d6c06db18f0 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: config_help.txt configure src/corelib/io/qprocess_wince.cpp src/plugins/platforms/windows/qwindowstheme.cpp src/plugins/platforms/xcb/qxcbbackingstore.cpp tests/auto/corelib/tools/qtimezone/BLACKLIST tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp Change-Id: I26644d1cb3b78412c8ff285e2a55bea1bd641c01
Diffstat (limited to 'src/network/kernel/qdnslookup_unix.cpp')
-rw-r--r--src/network/kernel/qdnslookup_unix.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
index d2c5542139..35981a2f2c 100644
--- a/src/network/kernel/qdnslookup_unix.cpp
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -42,7 +42,6 @@
#include <qlibrary.h>
#include <qscopedpointer.h>
#include <qurl.h>
-#include <private/qmutexpool_p.h>
#include <private/qnativesocketengine_p.h>
#include <sys/types.h>
@@ -78,7 +77,7 @@ struct QDnsLookupStateDeleter
}
};
-static void resolveLibrary()
+static bool resolveLibraryInternal()
{
QLibrary lib;
#ifdef LIBRESOLV_SO
@@ -88,7 +87,7 @@ static void resolveLibrary()
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
- return;
+ return false;
}
local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
@@ -112,19 +111,15 @@ static void resolveLibrary()
local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery"));
if (!local_res_nquery)
local_res_nquery = res_nquery_proto(lib.resolve("res_nquery"));
+
+ return true;
}
+Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal()))
void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
{
// Load dn_expand, res_ninit and res_nquery on demand.
- static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false);
- if (!triedResolve.loadAcquire()) {
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_ninit));
- if (!triedResolve.load()) {
- resolveLibrary();
- triedResolve.storeRelease(true);
- }
- }
+ resolveLibrary();
// If dn_expand, res_ninit or res_nquery is missing, fail.
if (!local_dn_expand || !local_res_nclose || !local_res_ninit || !local_res_nquery) {