mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[WINHTTP] Properly initialize winsock. Based on wine tests CORE-12104
svn path=/trunk/; revision=72951
This commit is contained in:
parent
0ebbe83388
commit
f58ddd3b46
|
@ -276,6 +276,28 @@ static BOOL ensure_cred_handle(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __REACTOS__
|
||||
static BOOL winsock_initialized = FALSE;
|
||||
BOOL netconn_init_winsock()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
int error;
|
||||
if (!winsock_initialized)
|
||||
{
|
||||
error = WSAStartup(MAKEWORD(1, 1), &wsaData);
|
||||
if (error)
|
||||
{
|
||||
ERR("WSAStartup failed: %d\n", error);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
winsock_initialized = TRUE;
|
||||
}
|
||||
return winsock_initialized;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BOOL netconn_init( netconn_t *conn )
|
||||
{
|
||||
memset(conn, 0, sizeof(*conn));
|
||||
|
@ -291,6 +313,10 @@ void netconn_unload( void )
|
|||
#ifndef HAVE_GETADDRINFO
|
||||
DeleteCriticalSection(&cs_gethostbyname);
|
||||
#endif
|
||||
#ifdef __REACTOS__
|
||||
if(winsock_initialized)
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL netconn_connected( netconn_t *conn )
|
||||
|
|
|
@ -83,9 +83,6 @@ static void session_destroy( object_header_t *hdr )
|
|||
heap_free( session->proxy_username );
|
||||
heap_free( session->proxy_password );
|
||||
heap_free( session );
|
||||
#ifdef __REACTOS__
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL session_query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen )
|
||||
|
@ -194,6 +191,9 @@ static const object_vtbl_t session_vtbl =
|
|||
session_set_option
|
||||
};
|
||||
|
||||
#ifdef __REACTOS__
|
||||
BOOL netconn_init_winsock();
|
||||
#endif /* __REACTOS__ */
|
||||
/***********************************************************************
|
||||
* WinHttpOpen (winhttp.@)
|
||||
*/
|
||||
|
@ -202,9 +202,7 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
|
|||
session_t *session;
|
||||
HINTERNET handle = NULL;
|
||||
#ifdef __REACTOS__
|
||||
WSADATA wsaData;
|
||||
int error = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (error) ERR("WSAStartup failed: %d\n", error);
|
||||
if (!netconn_init_winsock()) return NULL;
|
||||
#endif
|
||||
|
||||
TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
|
||||
|
|
Loading…
Reference in a new issue