diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-12-15 12:50:32 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-12-15 12:50:32 +0300 |
commit | c21efb9a856090d8ef0e5a7fdd03bf6346de4b60 (patch) | |
tree | 3244f466f271d4931c1020a6e7e795c021f76fb8 | |
parent | 4c0b8a072bc2877282383f799274361858ff1c3e (diff) |
* libc/minires-os-if.c (cygwin_query): Remove ERROR_PROC_NOT_FOUND case.
(get_dns_info): Verify DnsQuery exists. Use autoloaded GetNetworkParams.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/libc/minires-os-if.c | 26 |
2 files changed, 11 insertions, 20 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bd8cc5216..e4b48a323 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2006-12-15 Pierre A. Humblet <Pierre.Humblet@ieee.org> + + * libc/minires-os-if.c (cygwin_query): Remove ERROR_PROC_NOT_FOUND case. + (get_dns_info): Verify DnsQuery exists. Use autoloaded GetNetworkParams. + 2006-12-13 Corinna Vinschen <corinna@vinschen.de> * winsup.h (clear_procimptoken): Close hProcImpToken in a safer way. diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 28676cada..0f723ae34 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -196,10 +196,6 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty DPRINTF(debug, "DnsQuery: %lu (Windows)\n", res); if (res) { switch (res) { - case ERROR_PROC_NOT_FOUND: - errno = ENOSYS; - statp->res_h_errno = NO_RECOVERY; - break; case ERROR_INVALID_NAME: errno = EINVAL; statp->res_h_errno = NETDB_INTERNAL;; @@ -393,13 +389,12 @@ void get_dns_info(res_state statp) DWORD dwRetVal; IP_ADDR_STRING * pIPAddr; FIXED_INFO * pFixedInfo; - HINSTANCE kerneldll; - typedef DWORD WINAPI (*GNPType)(PFIXED_INFO, PULONG); - GNPType PGetNetworkParams; int numAddresses = 0; - if (statp->use_os) { - DPRINTF(debug, "using dnsapi.dll\n"); + if (statp->use_os + && ((dwRetVal = DnsQuery_A(NULL, 0, 0, NULL, NULL, NULL)) != ERROR_PROC_NOT_FOUND)) + { + DPRINTF(debug, "using dnsapi.dll %d\n", dwRetVal); statp->os_query = (typeof(statp->os_query)) cygwin_query; /* We just need the search list. Avoid loading iphlpapi. */ statp->nscount = -1; @@ -408,17 +403,8 @@ void get_dns_info(res_state statp) if (statp->nscount != 0) goto use_registry; - if (!(kerneldll = LoadLibrary("IPHLPAPI.DLL"))) { - DPRINTF(debug, "LoadLibrary: error %lu (Windows)\n", GetLastError()); - goto use_registry; - } - if (!(PGetNetworkParams = (GNPType) GetProcAddress(kerneldll, - "GetNetworkParams"))) { - DPRINTF(debug, "GetProcAddress: error %lu (Windows)\n", GetLastError()); - goto use_registry; - } /* First call to get the buffer length we need */ - dwRetVal = PGetNetworkParams((FIXED_INFO *) 0, &ulOutBufLen); + dwRetVal = GetNetworkParams((FIXED_INFO *) 0, &ulOutBufLen); if (dwRetVal != ERROR_BUFFER_OVERFLOW) { DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); goto use_registry; @@ -427,7 +413,7 @@ void get_dns_info(res_state statp) DPRINTF(debug, "alloca: %s\n", strerror(errno)); goto use_registry; } - if ((dwRetVal = PGetNetworkParams((FIXED_INFO *) pFixedInfo, & ulOutBufLen))) { + if ((dwRetVal = GetNetworkParams(pFixedInfo, & ulOutBufLen))) { DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); goto use_registry; } |