diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-01-13 13:16:11 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-01-16 23:24:52 +0100 |
commit | 127859483e0b957b2909f98d9e3e5f0d6f7a19b3 (patch) | |
tree | bccac9c56792e7e33e732b1536cdf21dcb41864c | |
parent | 92a6767337d69ae0c987ad08cd82aeca6e97bc25 (diff) | |
download | perl-smoke-me/destruct.tar.gz |
Don't set PL_perl_destruct_level = 2 as a side effect of use threads;smoke-me/destruct
There's no reason to enable full global destruction in the *top most thread*,
which is what the code used to do by setting PL_perl_destruct_level in a
BOOT block. The top most thread of an interpreter that has created threads
is no different to the only thread of an interpreter that has never created
threads, and we don't force full destruction there.
Instead, it only needs to be enabled in child threads, to ensure that they
are properly cleaned up.
I'm not confident that there are zero users out there on existing perls,
possibly in embedding scenarios, who are relying on some side effect of
setting destruction globally, so for now only enable this change on newer
perls. (As we expect people to have tested things more carefully before
upgrading their entire perl installation, and can't legislate against all
foolishness if they don't.)
-rw-r--r-- | dist/threads/lib/threads.pm | 2 | ||||
-rw-r--r-- | dist/threads/threads.xs | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/dist/threads/lib/threads.pm b/dist/threads/lib/threads.pm index 3c558865b5..b03aa9442d 100644 --- a/dist/threads/lib/threads.pm +++ b/dist/threads/lib/threads.pm @@ -5,7 +5,7 @@ use 5.008; use strict; use warnings; -our $VERSION = '1.86'; +our $VERSION = '1.87'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/dist/threads/threads.xs b/dist/threads/threads.xs index f6fe7dcd20..40e1e03dc6 100644 --- a/dist/threads/threads.xs +++ b/dist/threads/threads.xs @@ -779,6 +779,17 @@ S_ithread_create( thread->interp = perl_clone(aTHX, CLONEf_KEEP_PTR_TABLE); #endif +#if PERL_VERSION >= 15 + /* We only need total destruction on child threads. The parent thread + (the main interpreter) is no different from the "never created a + thread" case, and the destruct level is not forced to 2 there. + + This may be a not-entirely-compatible change, so for now, only enable + it for the next version of Perl 5. The old code remains in the BOOT + section. */ + thread->interp->Iperl_destruct_level = 2; +#endif + /* perl_clone() leaves us in new interpreter's context. As it is tricky * to spot an implicit aTHX, create a new scope with aTHX matching the * context for the duration of our work for new interpreter. @@ -1758,7 +1769,11 @@ BOOT: Zero(my_poolp, 1, my_pool_t); sv_setuv(my_pool_sv, PTR2UV(my_poolp)); + /* See the comment in S_ithread_create as to why this is conditionally + compiled in (for now), rather than simply removed. */ +# if PERL_VERSION < 15 PL_perl_destruct_level = 2; +# endif MUTEX_INIT(&MY_POOL.create_destruct_mutex); MUTEX_LOCK(&MY_POOL.create_destruct_mutex); |