[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:
Amine Khaldi 2016-09-20 09:42:51 +00:00
parent b257841ecd
commit e9878b1c6a
2 changed files with 26 additions and 6 deletions

View file

@ -114,8 +114,18 @@ static int in_cksum(u_short *addr, int len)
HANDLE WINAPI Icmp6CreateFile(VOID) HANDLE WINAPI Icmp6CreateFile(VOID)
{ {
icmp_t* icp; 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__ #ifndef __REACTOS__
if (sid < 0) if (sid < 0)
{ {
@ -133,6 +143,7 @@ HANDLE WINAPI Icmp6CreateFile(VOID)
if (icp==NULL) { if (icp==NULL) {
#ifdef __REACTOS__ #ifdef __REACTOS__
closesocket(sid); closesocket(sid);
WSACleanup();
#else #else
close(sid); close(sid);
#endif #endif
@ -180,8 +191,17 @@ HANDLE WINAPI IcmpCreateFile(VOID)
static int once; static int once;
#endif #endif
icmp_t* icp; 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__ #ifdef __REACTOS__
if (sid < 0) { if (sid < 0) {
ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n"); ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
@ -204,6 +224,7 @@ HANDLE WINAPI IcmpCreateFile(VOID)
if (icp==NULL) { if (icp==NULL) {
#ifdef __REACTOS__ #ifdef __REACTOS__
closesocket(sid); closesocket(sid);
WSACleanup();
#else #else
if (sid >= 0) close(sid); if (sid >= 0) close(sid);
#endif #endif
@ -235,6 +256,9 @@ BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
if (icp->sid >= 0) close(icp->sid); if (icp->sid >= 0) close(icp->sid);
#endif #endif
HeapFree(GetProcessHeap (), 0, icp); HeapFree(GetProcessHeap (), 0, icp);
#ifdef __REACTOS__
WSACleanup();
#endif
return TRUE; return TRUE;
} }

View file

@ -35,17 +35,13 @@ typedef struct _NAME_SERVER_LIST_CONTEXT {
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
WSADATA wsaData;
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinstDLL ); DisableThreadLibraryCalls( hinstDLL );
interfaceMapInit(); interfaceMapInit();
WSAStartup(MAKEWORD(2, 2), &wsaData);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
WSACleanup();
interfaceMapFree(); interfaceMapFree();
break; break;
} }