ws2_32: Warn the user when his host name is not resolvable
Bruno Jesus
00cpxxx at gmail.com
Tue Dec 30 23:34:15 CST 2014
A simpler approach to replace http://source.winehq.org/patches/data/108219.
-------------- next part --------------
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index b6aad67..c3ede5a 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -5621,19 +5621,19 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
struct addrinfo *unixaires = NULL;
int result;
struct addrinfo unixhints, *punixhints = NULL;
- char *hostname = NULL;
+ char *hostname;
const char *node;
*res = NULL;
if (!nodename && !servname) return WSAHOST_NOT_FOUND;
+ hostname = get_hostname();
+ if (!hostname) return WSA_NOT_ENOUGH_MEMORY;
+
if (!nodename)
node = NULL;
else if (!nodename[0])
- {
- node = hostname = get_hostname();
- if (!node) return WSA_NOT_ENOUGH_MEMORY;
- }
+ node = hostname;
else
node = nodename;
@@ -5677,6 +5677,12 @@ int WINAPI WS_getaddrinfo(LPCSTR nodename, LPCSTR servname, const struct WS_addr
/* getaddrinfo(3) is thread safe, no need to wrap in CS */
result = getaddrinfo(node, servname, punixhints, &unixaires);
+ if (result && !strcmp(hostname, node))
+ {
+ /* If it didn't work it means the host name IP is not in /etc/hosts */
+ ERR_(winediag)("Failed to resolve your host name address, the application may have problems "
+ "to work properly when accessing the network. You should fix this!\n");
+ }
TRACE("%s, %s %p -> %p %d\n", debugstr_a(nodename), debugstr_a(servname), hints, res, result);
HeapFree(GetProcessHeap(), 0, hostname);
More information about the wine-patches
mailing list