summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2011-10-07 12:45:47 (GMT)
committerJan-Arve Saether <jan-arve.saether@nokia.com>2011-10-07 12:45:47 (GMT)
commit1e8479b2aa781e6ce3fadf01294023fbc6ddbc22 (patch)
treef71430dfeddf810ab06ad496c3a31334537071ad /src/network/kernel
parenta0feeef52efde872c6d6e458c8e15616da0bf74f (diff)
downloadQt-1e8479b2aa781e6ce3fadf01294023fbc6ddbc22.zip
Qt-1e8479b2aa781e6ce3fadf01294023fbc6ddbc22.tar.gz
Qt-1e8479b2aa781e6ce3fadf01294023fbc6ddbc22.tar.bz2
don't lock the global mutex if there is nothing to protect
according to Thiago, setting the pointer with the same values *is* thread-safe Merge-request: 2655 Reviewed-by: Jan-Arve Saether <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/network/kernel')
-rw-r--r--src/network/kernel/qhostinfo_win.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index 03e72c4..1cbf350 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -45,9 +45,7 @@
#include "private/qnativesocketengine_p.h"
#include <ws2tcpip.h>
#include <private/qsystemlibrary_p.h>
-#include <qmutex.h>
#include <qurl.h>
-#include <private/qmutexpool_p.h>
QT_BEGIN_NAMESPACE
@@ -84,6 +82,10 @@ static void resolveLibrary()
{
// Attempt to resolve getaddrinfo(); without it we'll have to fall
// back to gethostbyname(), which has no IPv6 support.
+ static bool triedResolve = false;
+ if (triedResolve)
+ return;
+
#if !defined(Q_OS_WINCE)
QSystemLibrary ws2lib(QLatin1String("ws2_32"));
#else
@@ -94,6 +96,8 @@ static void resolveLibrary()
local_freeaddrinfo = (freeaddrinfoProto)ws2lib.resolve("freeaddrinfo");
local_getnameinfo = (getnameinfoProto)ws2lib.resolve("getnameinfo");
}
+
+ triedResolve = true;
}
#if defined(Q_OS_WINCE)
@@ -103,21 +107,13 @@ QMutex qPrivCEMutex;
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
+ resolveLibrary();
+
#if defined(Q_OS_WINCE)
QMutexLocker locker(&qPrivCEMutex);
#endif
QWindowsSockInit winSock;
- // Load res_init on demand.
- static volatile bool triedResolve = false;
- if (!triedResolve) {
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo));
- if (!triedResolve) {
- resolveLibrary();
- triedResolve = true;
- }
- }
-
QHostInfo results;
#if defined(QHOSTINFO_DEBUG)