summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2012-01-29 20:32:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-01 22:23:55 +0100
commitb69bb01f11f5104d8e807c7a2bdc92d3ffa394b4 (patch)
tree1f363f3922a4e51287bd0e6eac1b1f14ff2ba3b1 /src/network/kernel
parentc094891db377d750c0e8290b98971b69161a0552 (diff)
Use QBasicMutex instead of Q_GLOBAL_STATIC QMutex
QBasicMutex is a POD and can be used as a static global object. in qpicture.cpp factoryLoader is used only once, and under the mutex, so there is no need for Q_GLOBAL_STATIC for it, it can be a function static in qhostinfo_unix.cpp the code seemed wrong while compiled with namespace and QT_NO_GETADDRINFO. I also could get rid of one include because it was included earlier. Change-Id: I3c700203c3e067266c20733f4bda8031446dbb86 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/network/kernel')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp9
-rw-r--r--src/network/kernel/qhostinfo_win.cpp8
2 files changed, 5 insertions, 12 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 934d5c4c0e..71eb240812 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -63,10 +63,7 @@
#endif
#if defined (QT_NO_GETADDRINFO)
-#include <qmutex.h>
-QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QMutex, getHostByNameMutex)
-QT_END_NAMESPACE
+static QBasicMutex getHostByNameMutex;
#endif
QT_BEGIN_NAMESPACE
@@ -267,7 +264,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
// reentrant on all platforms. For now this is okay since we only
// use one QHostInfoAgent, but if more agents are introduced, locking
// must be provided.
- QMutexLocker locker(::getHostByNameMutex());
+ QMutexLocker locker(&getHostByNameMutex);
hostent *result = gethostbyname(aceHostname.constData());
if (result) {
if (result->h_addrtype == AF_INET) {
@@ -348,7 +345,7 @@ QString QHostInfo::localDomainName()
#if defined(QT_NO_GETADDRINFO)
// We have to call res_init to be sure that _res was initialized
// So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too
- QMutexLocker locker(::getHostByNameMutex());
+ QMutexLocker locker(&getHostByNameMutex);
#endif
local_res_init();
QString domainName = QUrl::fromAce(local_res->defdname);
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index be1d067cef..a00389e3ed 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -95,15 +95,11 @@ static void resolveLibrary()
#endif
}
-#if defined(Q_OS_WINCE)
-#include <qmutex.h>
-Q_GLOBAL_STATIC(QMutex, qPrivCEMutex)
-#endif
-
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
#if defined(Q_OS_WINCE)
- QMutexLocker locker(qPrivCEMutex());
+ static QBasicMutex qPrivCEMutex;
+ QMutexLocker locker(&qPrivCEMutex);
#endif
QWindowsSockInit winSock;