From: Jarkko Hietaniemi Date: Mon, 4 Dec 2006 22:53:03 +0000 (-0500) Subject: Re: When should PERL_SYS_TERM() be called? [was: Re: [PATCH] Re: [PATCH] Re: [PATCH... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3890ecea71e8d1097fd1d7614b8a095c06dbb4f5;p=p5sagit%2Fp5-mst-13.2.git Re: When should PERL_SYS_TERM() be called? [was: Re: [PATCH] Re: [PATCH] Re: [PATCH] abstract mempool header testing] Message-ID: <4574ED1F.40508@iki.fi> Re-instates #29424 (previously reverted by #29451), now fixed to work with PERL_IMPLICIT_SYS, thanks to Jan Dubois. Also adds PERLIO_TERM to the Symbian port. p4raw-id: //depot/perl@29465 --- diff --git a/perlio.c b/perlio.c index 4e69c61..0d91fb4 100644 --- a/perlio.c +++ b/perlio.c @@ -2412,19 +2412,19 @@ void PerlIO_teardown(pTHX) /* Call only from PERL_SYS_TERM(). */ } } #endif -#ifdef USE_ITHREADS - MUTEX_LOCK(&PL_perlio_mutex); -#endif +#if !defined(WIN32) || !defined(PERL_IMPLICIT_SYS) + /* On Windows, under PERL_IMPLICIT_SYS, all memory allocated by + * PerlMemShared_...() will be freed anyways when PL_curinterp + * is being destroyed. */ if (PL_perlio_fd_refcnt_size /* Assuming initial size of zero. */ && PL_perlio_fd_refcnt) { - PerlMemShared_free(PL_perlio_fd_refcnt); /* Not Safefree() because was allocated with PerlMemShared_realloc(). */ + /* Not bothering with PL_perlio_mutex since by now all the + * interpreters are gone. */ + PerlMemShared_free(PL_perlio_fd_refcnt); PL_perlio_fd_refcnt = NULL; PL_perlio_fd_refcnt_size = 0; } -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&PL_perlio_mutex); #endif - } diff --git a/symbian/symbianish.h b/symbian/symbianish.h index b2054bc..4eaffc3 100644 --- a/symbian/symbianish.h +++ b/symbian/symbianish.h @@ -120,7 +120,7 @@ #define Mkdir(path,mode) mkdir((path),(mode)) #ifndef PERL_SYS_TERM -#define PERL_SYS_TERM() HINTS_REFCNT_TERM; OP_REFCNT_TERM; MALLOC_TERM; CloseSTDLIB(); +#define PERL_SYS_TERM() HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; CloseSTDLIB(); #endif #define BIT_BUCKET "NUL:" diff --git a/win32/win32.c b/win32/win32.c index d53741c..a7c409f 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4902,11 +4902,10 @@ Perl_win32_init(int *argcp, char ***argvp) void Perl_win32_term(void) { + dTHX; HINTS_REFCNT_TERM; OP_REFCNT_TERM; - /* Can't call PERLIO_TERM here because that calls PerlMemShared_free() - * but we're too late for that (at least when using PERL_IMPLICIT_SYS) - * since we've already done perl_free(). */ + PERLIO_TERM; MALLOC_TERM; } diff --git a/win32/wince.c b/win32/wince.c index 6e876a8..846a33b 100644 --- a/win32/wince.c +++ b/win32/wince.c @@ -2660,11 +2660,10 @@ Perl_win32_init(int *argcp, char ***argvp) DllExport void Perl_win32_term(void) { + dTHX; HINTS_REFCNT_TERM; OP_REFCNT_TERM; - /* Can't call PERLIO_TERM here because that calls PerlMemShared_free() - * but we're too late for that (at least when using PERL_IMPLICIT_SYS) - * since we've already done perl_free(). */ + PERLIO_TERM; MALLOC_TERM; }