Re: [PATCH] Re: [PATCH] Re: [PATCH] abstract mempool header testing
Yves Orton [Sat, 2 Dec 2006 14:48:54 +0000 (15:48 +0100)]
Message-ID: <9b18b3110612020548l7c5aefd4m19cb0b5c4395abb4@mail.gmail.com>

p4raw-id: //depot/perl@29442

perlio.c
win32/perllib.c

index 2236c50..4e69c61 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -2398,6 +2398,7 @@ PerlIO_cleanup(pTHX)
 
 void PerlIO_teardown(pTHX) /* Call only from PERL_SYS_TERM(). */
 {
+    
 #ifdef DEBUGGING
     {
        /* By now all filehandles should have been closed, so any
@@ -2416,22 +2417,14 @@ void PerlIO_teardown(pTHX) /* Call only from PERL_SYS_TERM(). */
 #endif
     if (PL_perlio_fd_refcnt_size /* Assuming initial size of zero. */
         && PL_perlio_fd_refcnt) {
-#ifdef PERL_TRACK_MEMPOOL
-        Malloc_t ptr = (Malloc_t)((char*)PL_perlio_fd_refcnt-sTHX);
-        struct perl_memory_debug_header *const header
-            = (struct perl_memory_debug_header *)ptr;
-        /* Only the thread that allocated us can free us. */
-        if (header->interpreter == aTHX)
-#endif
-           {
-               PerlMemShared_free(PL_perlio_fd_refcnt); /* Not Safefree() because was allocated with PerlMemShared_realloc(). */
-               PL_perlio_fd_refcnt = NULL;
-               PL_perlio_fd_refcnt_size = 0;
-           }
+       PerlMemShared_free(PL_perlio_fd_refcnt); /* Not Safefree() because was allocated with PerlMemShared_realloc(). */
+       PL_perlio_fd_refcnt = NULL;
+       PL_perlio_fd_refcnt_size = 0;
     }
 #ifdef USE_ITHREADS
     MUTEX_UNLOCK(&PL_perlio_mutex);
 #endif
+    
 }
 
 
index 1e4ba09..d1afa16 100644 (file)
@@ -248,18 +248,28 @@ RunPerl(int argc, char **argv, char **env)
        exitstatus = perl_run(my_perl);
 #endif
     }
-
+    
     perl_destruct(my_perl);
-    perl_free(my_perl);
 #ifdef USE_ITHREADS
     if (new_perl) {
        PERL_SET_THX(new_perl);
        perl_destruct(new_perl);
+       PERL_SET_THX(my_perl);
+    }
+#endif
+    
+    PERL_SYS_TERM();
+    
+    perl_free(my_perl);
+    
+#ifdef USE_ITHREADS
+    if (new_perl) {
+       PERL_SET_THX(new_perl);
        perl_free(new_perl);
     }
 #endif
 
-    PERL_SYS_TERM();
+    
 
     return (exitstatus);
 }