Author: phater
Date: Mon Oct 10 06:54:56 2016
New Revision: 72951
URL:
http://svn.reactos.org/svn/reactos?rev=72951&view=rev
Log:
[WINHTTP] Properly initialize winsock. Based on wine tests CORE-12104
Modified:
trunk/reactos/dll/win32/winhttp/net.c
trunk/reactos/dll/win32/winhttp/session.c
Modified: trunk/reactos/dll/win32/winhttp/net.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/net.c?re…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] Mon Oct 10 06:54:56 2016
@@ -276,6 +276,28 @@
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));
@@ -290,6 +312,10 @@
DeleteCriticalSection(&init_sechandle_cs);
#ifndef HAVE_GETADDRINFO
DeleteCriticalSection(&cs_gethostbyname);
+#endif
+#ifdef __REACTOS__
+ if(winsock_initialized)
+ WSACleanup();
#endif
}
Modified: trunk/reactos/dll/win32/winhttp/session.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/session.…
==============================================================================
--- trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] Mon Oct 10 06:54:56 2016
@@ -83,9 +83,6 @@
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 @@
session_set_option
};
+#ifdef __REACTOS__
+BOOL netconn_init_winsock();
+#endif /* __REACTOS__ */
/***********************************************************************
* WinHttpOpen (winhttp.@)
*/
@@ -202,9 +202,7 @@
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);