From: Gisle Aas Date: Wed, 5 Jan 2005 03:21:06 +0000 (-0800) Subject: libperl leaks a THREAD_KEY each time it is reloaded X-Git-Tag: accepted/trunk/20130322.191538~21213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aebd1ac7983c6d00ee0b79f7eb3bc5904d3b2bdf;p=platform%2Fupstream%2Fperl.git libperl leaks a THREAD_KEY each time it is reloaded Message-ID: p4raw-id: //depot/perl@23890 --- diff --git a/perl.c b/perl.c index f242dfe..aad80ed 100644 --- a/perl.c +++ b/perl.c @@ -941,6 +941,31 @@ perl_free(pTHXx) #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) {