mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 15:08:14 +00:00
[IPHLPAPI] Don't (de)initialize ws2 on dll process (attach/detach), do it on IcmpCreateFile/IcmpCloseHandle instead, due to the circular dependency ws2_32 -> mswsock -> dnsapi(adns lib) -> iphlpapi -> ws2_32. This creates 2 references to ws2_32 and ws2_32 can't cleanup on WSACleanup. By Peter Hater. CORE-10440
svn path=/trunk/; revision=72747
This commit is contained in:
parent
b257841ecd
commit
e9878b1c6a
2 changed files with 26 additions and 6 deletions
|
@ -114,8 +114,18 @@ static int in_cksum(u_short *addr, int len)
|
|||
HANDLE WINAPI Icmp6CreateFile(VOID)
|
||||
{
|
||||
icmp_t* icp;
|
||||
int sid;
|
||||
#ifdef __REACTOS__
|
||||
WSADATA wsaData;
|
||||
|
||||
int sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
|
||||
{
|
||||
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
|
||||
#ifndef __REACTOS__
|
||||
if (sid < 0)
|
||||
{
|
||||
|
@ -133,6 +143,7 @@ HANDLE WINAPI Icmp6CreateFile(VOID)
|
|||
if (icp==NULL) {
|
||||
#ifdef __REACTOS__
|
||||
closesocket(sid);
|
||||
WSACleanup();
|
||||
#else
|
||||
close(sid);
|
||||
#endif
|
||||
|
@ -180,8 +191,17 @@ HANDLE WINAPI IcmpCreateFile(VOID)
|
|||
static int once;
|
||||
#endif
|
||||
icmp_t* icp;
|
||||
int sid;
|
||||
#ifdef __REACTOS__
|
||||
WSADATA wsaData;
|
||||
|
||||
int sid=socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
|
||||
{
|
||||
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
#endif
|
||||
sid=socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
|
||||
#ifdef __REACTOS__
|
||||
if (sid < 0) {
|
||||
ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
|
||||
|
@ -204,6 +224,7 @@ HANDLE WINAPI IcmpCreateFile(VOID)
|
|||
if (icp==NULL) {
|
||||
#ifdef __REACTOS__
|
||||
closesocket(sid);
|
||||
WSACleanup();
|
||||
#else
|
||||
if (sid >= 0) close(sid);
|
||||
#endif
|
||||
|
@ -235,6 +256,9 @@ BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
|
|||
if (icp->sid >= 0) close(icp->sid);
|
||||
#endif
|
||||
HeapFree(GetProcessHeap (), 0, icp);
|
||||
#ifdef __REACTOS__
|
||||
WSACleanup();
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,17 +35,13 @@ typedef struct _NAME_SERVER_LIST_CONTEXT {
|
|||
|
||||
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
|
||||
switch (fdwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls( hinstDLL );
|
||||
interfaceMapInit();
|
||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
WSACleanup();
|
||||
interfaceMapFree();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue