winsock cleanup never done on Windows (leads to handle leaks)
Gurusamy Sarathy [Wed, 5 Jul 2000 22:08:19 +0000 (22:08 +0000)]
p4raw-id: //depot/perl@6317

win32/perllib.c
win32/win32sck.c

index 857aada..fae3346 100644 (file)
@@ -338,6 +338,10 @@ RunPerl(int argc, char **argv, char **env)
 EXTERN_C void
 set_w32_module_name(void);
 
+EXTERN_C void
+EndSockets(void);
+
+
 #ifdef __MINGW32__
 EXTERN_C               /* GCC in C++ mode mangles the name, otherwise */
 #endif
@@ -367,6 +371,7 @@ DllMain(HANDLE hModule,             /* DLL module handle */
         * process termination or call to FreeLibrary.
         */
     case DLL_PROCESS_DETACH:
+       EndSockets();
        break;
 
        /* The attached process creates a new thread. */
index 93d501e..cc96688 100644 (file)
     } STMT_END
 #endif
 
-#define EndSockets() \
-    STMT_START {                                       \
-       if (wsock_started)                              \
-           WSACleanup();                               \
-    } STMT_END
-
 #define SOCKET_TEST(x, y) \
     STMT_START {                                       \
        StartSockets();                                 \
@@ -77,6 +71,13 @@ static struct servent* win32_savecopyservent(struct servent*d,
 
 static int wsock_started = 0;
 
+EXTERN_C void
+EndSockets(void)
+{
+    if (wsock_started)
+       WSACleanup();
+}
+
 void
 start_sockets(void) 
 {