wininet: Directly return error status from NETCON_init.

This commit is contained in:
Jacek Caban 2009-11-30 20:00:11 +01:00 committed by Alexandre Julliard
parent 1d96e20e8a
commit b01d58428b
3 changed files with 19 additions and 21 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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)