From: Ivailo Monev Date: Thu, 3 Aug 2017 07:16:00 +0000 (+0000) Subject: fix build against thread-unsafe resolv X-Git-Tag: 4.12.0~6324 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=84fb40aa59ab8912a70a652ce5e97c8806761907;p=kde%2FKatie.git fix build against thread-unsafe resolv Signed-off-by: Ivailo Monev --- diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index acfa84d41..49f6fc07d 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -60,27 +59,19 @@ #include #endif // QT_NO_RESOLV +QT_BEGIN_NAMESPACE + #if defined (QT_NO_GETADDRINFO) #include -QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QMutex, getHostByNameMutex) -QT_END_NAMESPACE #endif -QT_BEGIN_NAMESPACE - // HP-UXi has a bug in getaddrinfo(3) that makes it thread-unsafe // with this flag. So disable it in that platform. #if defined(AI_ADDRCONFIG) && !defined(Q_OS_HPUX) # define Q_ADDRCONFIG AI_ADDRCONFIG #endif -// a dirty way to support both thread-safe/unsafe -#if !defined(QT_NO_RESOLV) && !defined(res_ninit) -// if we can't get a thread-safe context, we have to use the global _res state -static __res_state* local_res = _res; -#endif // QT_NO_RESOLV - QHostInfo QHostInfoAgent::fromName(const QString &hostName) { QHostInfo results; @@ -281,6 +272,7 @@ QString QHostInfo::localHostName() QString QHostInfo::localDomainName() { +// a dirty way to support both thread-safe/unsafe #if !defined(QT_NO_RESOLV) && defined(res_ninit) // using thread-safe version res_state state = static_cast(malloc(sizeof(res_state))); @@ -303,9 +295,9 @@ QString QHostInfo::localDomainName() QMutexLocker locker(::getHostByNameMutex()); #endif res_init(); - QString domainName = QUrl::fromAce(local_res->defdname); + QString domainName = QUrl::fromAce(_res.defdname); if (domainName.isEmpty()) - domainName = QUrl::fromAce(local_res->dnsrch[0]); + domainName = QUrl::fromAce(_res.dnsrch[0]); return domainName; #else