summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qdnslookup_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-04-28 18:36:31 -0700
committerThiago Macieira <thiago.macieira@intel.com>2016-04-30 03:01:10 +0000
commitc9f9f54d3f79915723270b2a6d06216a54c87433 (patch)
treeaed56cca07c1e35426f3c1f25d453429d9144937 /src/network/kernel/qdnslookup_unix.cpp
parentfda6324b4d471c2163c94d0c451a4bb4671b7b18 (diff)
Remove the use of QMutexPool in QHostInfo and QDnsLookup
Q_GLOBAL_STATIC does the thread-safe protection for us. And who said we could only use non-POD types? We can just use a boolean! Change-Id: Ifea6e497f11a461db432ffff1449b0a88d75d194 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
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 dc8ec5a300..cb3bdfe8ff 100644
--- a/src/network/kernel/qdnslookup_unix.cpp
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -36,7 +36,6 @@
#include <qlibrary.h>
#include <qscopedpointer.h>
#include <qurl.h>
-#include <private/qmutexpool_p.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -71,7 +70,7 @@ struct QDnsLookupStateDeleter
}
};
-static void resolveLibrary()
+static bool resolveLibraryInternal()
{
QLibrary lib;
#ifdef LIBRESOLV_SO
@@ -81,7 +80,7 @@ static void resolveLibrary()
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
- return;
+ return false;
}
local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
@@ -105,19 +104,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) {