Skip to content

Commit 81fee9c

Browse files
committed
Fix DNS lookup
1 parent 3526498 commit 81fee9c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

common/gsPlatformUtil.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void * gsiResolveHostnameThread(void * arg)
173173
SocketStartUp();
174174

175175
memset(&hints, 0, sizeof(struct addrinfo));
176-
hints.ai_family = PF_UNSPEC;
176+
hints.ai_family = AF_INET;
177177
hints.ai_socktype = SOCK_STREAM;
178178

179179
// DNS lookup (works with pthreads)
@@ -182,7 +182,7 @@ static void * gsiResolveHostnameThread(void * arg)
182182
if (!error)
183183
{
184184
// first convert to character string for debug output
185-
ip = inet_ntoa((*(struct sockaddr_in*)result->ai_addr).sin_addr);
185+
ip = inet_ntoa( ((struct sockaddr_in*)result->ai_addr)->sin_addr);
186186

187187
gsDebugFormat(GSIDebugCat_HTTP, GSIDebugType_State, GSIDebugLevel_Comment,
188188
"Resolved host '%s' to ip '%s'\n", handle->hostname, ip);
@@ -318,9 +318,13 @@ unsigned int gsiGetResolvedIP(GSIResolveHostnameHandle handle)
318318
// free resources
319319
gsiCleanupThread(handle->threadID);
320320
gsifree(handle->hostname);
321+
handle->hostname = NULL;
321322
gsifree(handle);
322323
handle = NULL;
323324

325+
if (!ip)
326+
ip = GSI_ERROR_RESOLVING_HOSTNAME;
327+
324328
return ip;
325329
}
326330

0 commit comments

Comments
 (0)