diff options
author | Liang Qi <liang.qi@qt.io> | 2016-05-06 09:07:18 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-05-06 15:36:44 +0200 |
commit | dbef41f43ece97d8ac4d6b63f7a36afcb7e7b7f7 (patch) | |
tree | 334ebaec198a7f31d1e3a4639c70fbb8bb116af2 /src/network/kernel/qhostinfo_unix.cpp | |
parent | 52d30e2850769d589772576e4714a14241c7da6e (diff) | |
parent | f57d8f1341587e6b2aa84b8404aa218432584206 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
examples/qtestlib/tutorial5/containers.cpp
examples/widgets/tools/tools.pro
src/corelib/io/qprocess.cpp
src/corelib/io/qprocess_unix.cpp
src/corelib/io/qprocess_win.cpp
src/network/kernel/qdnslookup_unix.cpp
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/testlib/qtestcase.cpp
tools/configure/configureapp.cpp
Change-Id: I838ae7f082535a67a4a53aa13a21ba5580758be8
Diffstat (limited to 'src/network/kernel/qhostinfo_unix.cpp')
-rw-r--r-- | src/network/kernel/qhostinfo_unix.cpp | 17 |
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) |