summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qhostinfo_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qhostinfo_unix.cpp')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 8a3f3fa5c9..7af8db73e0 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -49,7 +49,6 @@
#include <qbasicatomic.h>
#include <qurl.h>
#include <qfile.h>
-#include <private/qmutexpool_p.h>
#include <private/qnet_unix_p.h>
#include <sys/types.h>
@@ -92,7 +91,7 @@ typedef void (*res_nclose_proto)(res_state_ptr);
static res_nclose_proto local_res_nclose = 0;
static res_state_ptr local_res = 0;
-static void resolveLibrary()
+static bool resolveLibraryInternal()
{
#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_QNX)
QLibrary lib;
@@ -103,7 +102,7 @@ static void resolveLibrary()
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
- return;
+ return false;
}
local_res_init = res_init_proto(lib.resolve("__res_init"));
@@ -125,7 +124,10 @@ static void resolveLibrary()
local_res_ninit = 0;
}
#endif
+
+ return true;
}
+Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal()))
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
@@ -137,14 +139,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
#endif
// Load res_init on demand.
- static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false);
- if (!triedResolve.loadAcquire()) {
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_init));
- if (!triedResolve.load()) {
- resolveLibrary();
- triedResolve.storeRelease(true);
- }
- }
+ resolveLibrary();
// If res_init is available, poll it.
if (local_res_init)