Change 23890 by [EMAIL PROTECTED] on 2005/01/27 17:49:50

        Subject: [PATCH] libperl leaks a THREAD_KEY each time it is reloaded
        From: Gisle Aas <[EMAIL PROTECTED]>
        Date: 05 Jan 2005 03:21:06 -0800
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/perl.c#582 edit

Differences ...

==== //depot/perl/perl.c#582 (text) ====
Index: perl/perl.c
--- perl/perl.c#581~23824~      Wed Jan 19 10:32:41 2005
+++ perl/perl.c Thu Jan 27 09:49:50 2005
@@ -941,6 +941,31 @@
 #endif
 }
 
+#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
+/* provide destructors to clean up the thread key when libperl is unloaded */
+#ifndef WIN32 /* handled during DLL_PROCESS_DETACH in win32/perllib.c */
+
+#if defined(__hpux) && !defined(__GNUC__)
+#pragma fini "perl_fini"
+#endif
+
+#if defined(__GNUC__) && defined(__attribute__) 
+/* want to make sure __attribute__ works here even
+ * for -Dd_attribut=undef builds.
+ */
+#undef __attribute__
+#endif
+
+static void __attribute__((destructor))
+perl_fini()
+{
+    if (PL_curinterp)
+       FREE_THREAD_KEY;
+}
+
+#endif /* WIN32 */
+#endif /* THREADS */
+
 void
 Perl_call_atexit(pTHX_ ATEXIT_t fn, void *ptr)
 {
End of Patch.

Reply via email to