From: Vincent Pit Date: Mon, 29 Sep 2014 14:20:43 +0000 (+0200) Subject: When a pseudo-fork ends, execute the cleanup hooks after global END blocks X-Git-Tag: v0.07~2 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FThread-Cleanup.git;a=commitdiff_plain;h=cc6a2e4288f5e12c19ba7d09e9c82e7f5f1e8bfa When a pseudo-fork ends, execute the cleanup hooks after global END blocks --- diff --git a/Cleanup.xs b/Cleanup.xs index 43ab949..4fd00ec 100644 --- a/Cleanup.xs +++ b/Cleanup.xs @@ -65,9 +65,8 @@ PPCODE: CV *cv = GvCV(gv); if (!PL_endav) PL_endav = newAV(); - av_unshift(PL_endav, 1); SvREFCNT_inc(cv); - if (!av_store(PL_endav, 0, (SV *) cv)) + if (!av_store(PL_endav, av_len(PL_endav) + 1, (SV *) cv)) SvREFCNT_dec(cv); sv_magicext((SV *) PL_endav, NULL, PERL_MAGIC_ext, &tc_endav_vtbl, NULL, 0); } diff --git a/lib/Thread/Cleanup.pm b/lib/Thread/Cleanup.pm index 3c2a5e8..fc0435c 100644 --- a/lib/Thread/Cleanup.pm +++ b/lib/Thread/Cleanup.pm @@ -64,7 +64,7 @@ For detached threads, it will be called if and only if the thread terminates bef =item * -For pseudo-forks, it will be called when C succeeds, after any C block local to the spawn process but before any global C block ; +For pseudo-forks, it will be called when C succeeds, after any local or global C block ; =item * diff --git a/t/30-pseudoforks.t b/t/30-pseudoforks.t index 2247c40..fc9e417 100644 --- a/t/30-pseudoforks.t +++ b/t/30-pseudoforks.t @@ -38,7 +38,7 @@ if ($pid) { Thread::Cleanup::register { pass 'pseudo-fork destructor called'; is $local_end, 1, 'pseudo-fork destructor called after local END block'; - is $global_end, 0, 'pseudo-fork destructor called before global END block'; + is $global_end, 1, 'pseudo-fork destructor called after global END block'; is $gd, 0, 'pseudo-fork destructor called before global destruction'; };