Jacek Caban : wininet: Directly return error status from NETCON_init.

Alexandre Julliard julliard at winehq.org
Tue Dec 1 09:19:41 CST 2009


Module: wine
Branch: master
Commit: b01d58428b2c38f1b594064d7028e43a75885103
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b01d58428b2c38f1b594064d7028e43a75885103

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Nov 30 20:00:11 2009 +0100

wininet: Directly return error status from NETCON_init.

---

 dlls/wininet/http.c          |   11 ++++++++---
 dlls/wininet/internet.h      |    2 +-
 dlls/wininet/netconnection.c |   27 ++++++++++-----------------
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 6a45ea4..5c504d4 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2594,7 +2594,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(http_session_t *lpwhs,
     LPWSTR lpszHostName = NULL;
     HINTERNET handle = NULL;
     static const WCHAR szHostForm[] = {'%','s',':','%','u',0};
-    DWORD len;
+    DWORD len, res;
 
     TRACE("-->\n");
 
@@ -2636,10 +2636,11 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(http_session_t *lpwhs,
         goto lend;
     }
 
-    if (!NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE))
+    if ((res = NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE)) != ERROR_SUCCESS)
     {
         InternetCloseHandle( handle );
         handle = NULL;
+        INTERNET_SetLastError(res);
         goto lend;
     }
 
@@ -3694,7 +3695,11 @@ static BOOL HTTP_HandleRedirect(http_request_t *lpwhr, LPCWSTR lpszUrl)
                     INTERNET_SetLastError(res);
                     return FALSE;
                 }
-                if (!NETCON_init(&lpwhr->netConnection, lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE)) return FALSE;
+                res = NETCON_init(&lpwhr->netConnection, lpwhr->hdr.dwFlags & INTERNET_FLAG_SECURE);
+                if (res != ERROR_SUCCESS) {
+                    INTERNET_SetLastError(res);
+                    return FALSE;
+                }
                 lpwhr->read_pos = lpwhr->read_size = 0;
                 lpwhr->read_chunked = FALSE;
             }
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 75cd676..b9612b2 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -428,7 +428,7 @@ VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
                            DWORD dwStatusInfoLength);
 
 BOOL NETCON_connected(WININET_NETCONNECTION *connection);
-BOOL NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
+DWORD NETCON_init(WININET_NETCONNECTION *connnection, BOOL useSSL);
 void NETCON_unload(void);
 DWORD NETCON_create(WININET_NETCONNECTION *connection, int domain,
 	      int type, int protocol);
diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c
index 013789b..1f95dcb 100644
--- a/dlls/wininet/netconnection.c
+++ b/dlls/wininet/netconnection.c
@@ -163,7 +163,7 @@ static void ssl_lock_callback(int mode, int type, const char *file, int line)
 
 #endif
 
-BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
+DWORD NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
 {
     connection->useSSL = FALSE;
     connection->socketFD = -1;
@@ -177,25 +177,23 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
 	if (OpenSSL_ssl_handle) /* already initialized everything */
         {
             LeaveCriticalSection(&init_ssl_cs);
-            return TRUE;
+            return ERROR_SUCCESS;
         }
 	OpenSSL_ssl_handle = wine_dlopen(SONAME_LIBSSL, RTLD_NOW, NULL, 0);
 	if (!OpenSSL_ssl_handle)
 	{
 	    ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n",
 		SONAME_LIBSSL);
-            INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR);
             LeaveCriticalSection(&init_ssl_cs);
-            return FALSE;
+            return ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
 	}
 	OpenSSL_crypto_handle = wine_dlopen(SONAME_LIBCRYPTO, RTLD_NOW, NULL, 0);
 	if (!OpenSSL_crypto_handle)
 	{
 	    ERR("trying to use a SSL connection, but couldn't load %s. Expect trouble.\n",
 		SONAME_LIBCRYPTO);
-            INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR);
             LeaveCriticalSection(&init_ssl_cs);
-            return FALSE;
+            return ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
 	}
 
         /* mmm nice ugly macroness */
@@ -204,9 +202,8 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
     if (!p##x) \
     { \
         ERR("failed to load symbol %s\n", #x); \
-        INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \
         LeaveCriticalSection(&init_ssl_cs); \
-        return FALSE; \
+        return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; \
     }
 
 	DYNSSL(SSL_library_init);
@@ -234,9 +231,8 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
     if (!p##x) \
     { \
         ERR("failed to load symbol %s\n", #x); \
-        INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR); \
         LeaveCriticalSection(&init_ssl_cs); \
-        return FALSE; \
+        return ERROR_INTERNET_SECURITY_CHANNEL_ERROR; \
     }
 	DYNCRYPTO(BIO_new_fp);
 	DYNCRYPTO(CRYPTO_num_locks);
@@ -257,9 +253,8 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
         {
             ERR("SSL_CTX_set_default_verify_paths failed: %s\n",
                 pERR_error_string(pERR_get_error(), 0));
-            INTERNET_SetLastError(ERROR_OUTOFMEMORY);
             LeaveCriticalSection(&init_ssl_cs);
-            return FALSE;
+            return ERROR_OUTOFMEMORY;
         }
 
         pCRYPTO_set_id_callback(ssl_thread_id);
@@ -267,9 +262,8 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
                 pCRYPTO_num_locks() * sizeof(CRITICAL_SECTION));
         if (!ssl_locks)
         {
-            INTERNET_SetLastError(ERROR_OUTOFMEMORY);
             LeaveCriticalSection(&init_ssl_cs);
-            return FALSE;
+            return ERROR_OUTOFMEMORY;
         }
         for (i = 0; i < pCRYPTO_num_locks(); i++)
             InitializeCriticalSection(&ssl_locks[i]);
@@ -277,11 +271,10 @@ BOOL NETCON_init(WININET_NETCONNECTION *connection, BOOL useSSL)
         LeaveCriticalSection(&init_ssl_cs);
 #else
 	FIXME("can't use SSL, not compiled in.\n");
-        INTERNET_SetLastError(ERROR_INTERNET_SECURITY_CHANNEL_ERROR);
-        return FALSE;
+        return ERROR_INTERNET_SECURITY_CHANNEL_ERROR;
 #endif
     }
-    return TRUE;
+    return ERROR_SUCCESS;
 }
 
 void NETCON_unload(void)




More information about the wine-cvs mailing list