wine/dlls/wininet utility.c internet.h http.c ...

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 15 12:16:55 CST 2005


ChangeSet ID:	21289
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/15 12:16:55

Modified files:
	dlls/wininet   : utility.c internet.h http.c ftp.c 

Log message:
	Robert Shearman <rob at codeweavers.com>
	We shouldn't pass the struct hostent returned from gethostbyname as
	it's not thread-safe and isn't needed anyway.

Patch: http://cvs.winehq.org/patch.py?id=21289

Old revision  New revision  Changes     Path
 1.28          1.29          +6 -5       wine/dlls/wininet/utility.c
 1.40          1.41          +1 -3       wine/dlls/wininet/internet.h
 1.109         1.110         +3 -3       wine/dlls/wininet/http.c
 1.57          1.58          +1 -3       wine/dlls/wininet/ftp.c

Index: wine/dlls/wininet/utility.c
diff -u -p wine/dlls/wininet/utility.c:1.28 wine/dlls/wininet/utility.c:1.29
--- wine/dlls/wininet/utility.c:1.28	15 Nov 2005 18:16:55 -0000
+++ wine/dlls/wininet/utility.c	15 Nov 2005 18:16:55 -0000
@@ -127,11 +127,12 @@ time_t ConvertTimeString(LPCWSTR asctime
 
 
 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
-	struct hostent **phe, struct sockaddr_in *psa)
+	struct sockaddr_in *psa)
 {
     WCHAR *found;
     char *name;
     int len, sz;
+    struct hostent *phe;
 
     TRACE("%s\n", debugstr_w(lpszServerName));
 
@@ -150,18 +151,18 @@ BOOL GetAddress(LPCWSTR lpszServerName, 
     name = HeapAlloc(GetProcessHeap(), 0, sz+1);
     WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL );
     name[sz] = 0;
-    *phe = gethostbyname(name);
+    phe = gethostbyname(name);
     HeapFree( GetProcessHeap(), 0, name );
 
-    if (NULL == *phe)
+    if (NULL == phe)
     {
         TRACE("Failed to get hostname: (%s)\n", debugstr_w(lpszServerName) );
         return FALSE;
     }
 
     memset(psa,0,sizeof(struct sockaddr_in));
-    memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
-    psa->sin_family = (*phe)->h_addrtype;
+    memcpy((char *)&psa->sin_addr, phe->h_addr, phe->h_length);
+    psa->sin_family = phe->h_addrtype;
     psa->sin_port = htons((u_short)nServerPort);
 
     return TRUE;
Index: wine/dlls/wininet/internet.h
diff -u -p wine/dlls/wininet/internet.h:1.40 wine/dlls/wininet/internet.h:1.41
--- wine/dlls/wininet/internet.h:1.40	15 Nov 2005 18:16:55 -0000
+++ wine/dlls/wininet/internet.h	15 Nov 2005 18:16:55 -0000
@@ -168,7 +168,6 @@ typedef struct
     LPWSTR  lpszUserName;
     INTERNET_PORT nServerPort;
     struct sockaddr_in socketAddress;
-    struct hostent *phostent;
 } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;
 
 #define HDR_ISREQUEST		0x0001
@@ -214,7 +213,6 @@ typedef struct
     LPWININETFILE download_in_progress;
     struct sockaddr_in socketAddress;
     struct sockaddr_in lstnSocketAddress;
-    struct hostent *phostent;
     LPWSTR  lpszPassword;
     LPWSTR  lpszUserName;
 } WININETFTPSESSIONW, *LPWININETFTPSESSIONW;
@@ -420,7 +418,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW
 	DWORD dwInternalFlags);
 
 BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
-	struct hostent **phe, struct sockaddr_in *psa);
+	struct sockaddr_in *psa);
 
 void INTERNET_SetLastError(DWORD dwError);
 DWORD INTERNET_GetLastError(void);
Index: wine/dlls/wininet/http.c
diff -u -p wine/dlls/wininet/http.c:1.109 wine/dlls/wininet/http.c:1.110
--- wine/dlls/wininet/http.c:1.109	15 Nov 2005 18:16:55 -0000
+++ wine/dlls/wininet/http.c	15 Nov 2005 18:16:55 -0000
@@ -813,7 +813,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(L
                       strlenW(lpwhs->lpszServerName)+1);
 
     if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
-                    &lpwhs->phostent, &lpwhs->socketAddress))
+                    &lpwhs->socketAddress))
     {
         INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
         InternetCloseHandle( handle );
@@ -1397,7 +1397,7 @@ static BOOL HTTP_HandleRedirect(LPWININE
                       strlenW(lpwhs->lpszServerName)+1);
 
         if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
-                    &lpwhs->phostent, &lpwhs->socketAddress))
+                    &lpwhs->socketAddress))
         {
             INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
             return FALSE;
@@ -1917,7 +1917,7 @@ static BOOL HTTP_OpenConnection(LPWININE
                       &(lpwhs->socketAddress),
                        sizeof(struct sockaddr_in));
 
-    if (!NETCON_create(&lpwhr->netConnection, lpwhs->phostent->h_addrtype,
+    if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.sin_family,
                          SOCK_STREAM, 0))
     {
 	WARN("Socket creation failed\n");
Index: wine/dlls/wininet/ftp.c
diff -u -p wine/dlls/wininet/ftp.c:1.57 wine/dlls/wininet/ftp.c:1.58
--- wine/dlls/wininet/ftp.c:1.57	15 Nov 2005 18:16:55 -0000
+++ wine/dlls/wininet/ftp.c	15 Nov 2005 18:16:55 -0000
@@ -1656,7 +1656,6 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW 
     static const WCHAR szDefaultUsername[] = {'a','n','o','n','y','m','o','u','s','\0'};
     static const WCHAR szDefaultPassword[] = {'u','s','e','r','@','s','e','r','v','e','r','\0'};
     struct sockaddr_in socketAddr;
-    struct hostent *phe = NULL;
     INT nsocket = -1;
     UINT sock_namelen;
     BOOL bSuccess = FALSE;
@@ -1734,7 +1733,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW 
     SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_RESOLVING_NAME,
         (LPWSTR) lpszServerName, strlenW(lpszServerName));
 
-    if (!GetAddress(lpszServerName, nServerPort, &phe, &socketAddr))
+    if (!GetAddress(lpszServerName, nServerPort, &socketAddr))
     {
 	INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
         goto lerror;
@@ -1767,7 +1766,6 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW 
 
 	sock_namelen = sizeof(lpwfs->socketAddress);
 	getsockname(nsocket, (struct sockaddr *) &lpwfs->socketAddress, &sock_namelen);
-        lpwfs->phostent = phe;
 
         if (FTP_ConnectToHost(lpwfs))
         {



More information about the wine-cvs mailing list