This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: When should PERL_SYS_TERM() be called? [was: Re: [PATCH] Re: [PATCH] Re: [PATCH...
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 4 Dec 2006 22:53:03 +0000 (17:53 -0500)
committerSteve Hay <SteveHay@planit.com>
Tue, 5 Dec 2006 09:41:44 +0000 (09:41 +0000)
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

perlio.c
symbian/symbianish.h
win32/win32.c
win32/wince.c

index 4e69c61..0d91fb4 100644 (file)
--- 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
-    
 }
 
 
index b2054bc..4eaffc3 100644 (file)
 #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:"
index d53741c..a7c409f 100644 (file)
@@ -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;
 }
 
index 6e876a8..846a33b 100644 (file)
@@ -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;
 }