Change 29827 by [EMAIL PROTECTED] on 2007/01/15 14:16:53

        extend threads 'veto cleanup' to perl_free and system stuff

Affected files ...

... //depot/perl/embedvar.h#235 edit
... //depot/perl/perl.c#780 edit
... //depot/perl/perlapi.h#157 edit
... //depot/perl/perlvars.h#72 edit
... //depot/perl/unixish.h#44 edit

Differences ...

==== //depot/perl/embedvar.h#235 (text+w) ====
Index: perl/embedvar.h
--- perl/embedvar.h#234~29655~  2007-01-01 17:51:05.000000000 -0800
+++ perl/embedvar.h     2007-01-15 06:16:53.000000000 -0800
@@ -800,6 +800,8 @@
 #define PL_Gtimesbase          (my_vars->Gtimesbase)
 #define PL_use_safe_putenv     (my_vars->Guse_safe_putenv)
 #define PL_Guse_safe_putenv    (my_vars->Guse_safe_putenv)
+#define PL_veto_cleanup                (my_vars->Gveto_cleanup)
+#define PL_Gveto_cleanup       (my_vars->Gveto_cleanup)
 #define PL_watch_pvx           (my_vars->Gwatch_pvx)
 #define PL_Gwatch_pvx          (my_vars->Gwatch_pvx)
 
@@ -840,6 +842,7 @@
 #define PL_Gthr_key            PL_thr_key
 #define PL_Gtimesbase          PL_timesbase
 #define PL_Guse_safe_putenv    PL_use_safe_putenv
+#define PL_Gveto_cleanup       PL_veto_cleanup
 #define PL_Gwatch_pvx          PL_watch_pvx
 
 #endif /* PERL_GLOBAL_STRUCT */

==== //depot/perl/perl.c#780 (text) ====
Index: perl/perl.c
--- perl/perl.c#779~29762~      2007-01-11 09:27:02.000000000 -0800
+++ perl/perl.c 2007-01-15 06:16:53.000000000 -0800
@@ -580,6 +580,7 @@
 
     if (CALL_FPTR(PL_threadhook)(aTHX)) {
         /* Threads hook has vetoed further cleanup */
+       PL_veto_cleanup = TRUE;
         return STATUS_EXIT;
     }
 
@@ -1325,6 +1326,9 @@
 void
 perl_free(pTHXx)
 {
+    if (PL_veto_cleanup)
+       return;
+
 #ifdef PERL_TRACK_MEMPOOL
     {
        /*
@@ -1381,7 +1385,7 @@
 perl_fini(void)
 {
     dVAR;
-    if (PL_curinterp)
+    if (PL_curinterp  && !PL_veto_cleanup)
        FREE_THREAD_KEY;
 }
 

==== //depot/perl/perlapi.h#157 (text+w) ====
Index: perl/perlapi.h
--- perl/perlapi.h#156~29655~   2007-01-01 17:51:05.000000000 -0800
+++ perl/perlapi.h      2007-01-15 06:16:53.000000000 -0800
@@ -864,6 +864,8 @@
 #define PL_timesbase           (*Perl_Gtimesbase_ptr(NULL))
 #undef  PL_use_safe_putenv
 #define PL_use_safe_putenv     (*Perl_Guse_safe_putenv_ptr(NULL))
+#undef  PL_veto_cleanup
+#define PL_veto_cleanup                (*Perl_Gveto_cleanup_ptr(NULL))
 #undef  PL_watch_pvx
 #define PL_watch_pvx           (*Perl_Gwatch_pvx_ptr(NULL))
 

==== //depot/perl/perlvars.h#72 (text) ====
Index: perl/perlvars.h
--- perl/perlvars.h#71~29407~   2006-11-28 06:59:03.000000000 -0800
+++ perl/perlvars.h     2007-01-15 06:16:53.000000000 -0800
@@ -146,3 +146,8 @@
 #if defined(USE_ITHREADS)
 PERLVAR(Gperlio_mutex, perl_mutex)    /* Mutex for perlio fd refcounts */
 #endif
+
+/* this is currently set without MUTEX protection, so keep it a type which
+ * can be set atomically (ie not a bit field) */
+PERLVARI(Gveto_cleanup,        int, FALSE)     /* exit without cleanup */
+

==== //depot/perl/unixish.h#44 (text) ====
Index: perl/unixish.h
--- perl/unixish.h#43~29695~    2007-01-05 02:34:36.000000000 -0800
+++ perl/unixish.h      2007-01-15 06:16:53.000000000 -0800
@@ -132,7 +132,11 @@
 #endif
 
 #ifndef PERL_SYS_TERM
-#  define PERL_SYS_TERM()              HINTS_REFCNT_TERM; OP_REFCNT_TERM; 
PERLIO_TERM; MALLOC_TERM
+#  define PERL_SYS_TERM() \
+    if (!PL_veto_cleanup) { \
+       HINTS_REFCNT_TERM; OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; \
+    }
+
 #endif
 
 #define BIT_BUCKET "/dev/null"
End of Patch.

Reply via email to