From c4eea513602bdfcb39e14a79fbe01286e453dbcb Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 1 Mar 2012 15:49:20 +0000 Subject: resync QDnsLookup for win32 with Qt5 --- src/base/qdnslookup_win.cpp | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'src/base') diff --git a/src/base/qdnslookup_win.cpp b/src/base/qdnslookup_win.cpp index 87d6955a..d89ec623 100644 --- a/src/base/qdnslookup_win.cpp +++ b/src/base/qdnslookup_win.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include "qdnslookup_p.h" #include @@ -47,48 +48,14 @@ #include #include -#include QT_BEGIN_NAMESPACE -static QMutex local_dns_mutex; -typedef DNS_STATUS (*dns_query_utf8_proto)(PCSTR,WORD,DWORD,PIP4_ARRAY,PDNS_RECORD*,PVOID*); -static dns_query_utf8_proto local_dns_query_utf8 = 0; -typedef void (*dns_record_list_free_proto)(PDNS_RECORD,DNS_FREE_TYPE); -static dns_record_list_free_proto local_dns_record_list_free = 0; - -static void resolveLibrary() -{ - QLibrary lib(QLatin1String("dnsapi")); - if (!lib.load()) - return; - - local_dns_query_utf8 = (dns_query_utf8_proto) lib.resolve(QLatin1String("dnsapi"), "DnsQuery_UTF8"); - local_dns_record_list_free = (dns_record_list_free_proto) lib.resolve(QLatin1String("dnsapi"), "DnsRecordListFree"); -} - void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) { - // Load DnsQuery_UTF8 and DnsRecordListFree on demand. - static volatile bool triedResolve = false; - if (!triedResolve) { - QMutexLocker locker(&local_dns_mutex); - if (!triedResolve) { - resolveLibrary(); - triedResolve = true; - } - } - - // If DnsQuery_UTF8 or DnsRecordListFree is missing, fail. - if (!local_dns_query_utf8 || !local_dns_record_list_free) { - reply->error = QDnsLookup::ResolverError, - reply->errorString = tr("Resolver functions not found"); - return; - } - // Perform DNS query. - PDNS_RECORD dns_records; - const DNS_STATUS status = local_dns_query_utf8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); + PDNS_RECORD dns_records = 0; + const DNS_STATUS status = DnsQuery_UTF8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); switch (status) { case ERROR_SUCCESS: break; @@ -177,7 +144,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN } } - local_dns_record_list_free(dns_records, DnsFreeRecordList); + DnsRecordListFree(dns_records, DnsFreeRecordList); } QT_END_NAMESPACE -- cgit v1.2.3