From: Vincent Pit Date: Thu, 26 Nov 2009 21:10:19 +0000 (+0100) Subject: Empty the global pointer table at the end of a thread X-Git-Tag: v0.39~14 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=cb678e6b73356092edce6d42b76f3d667f95d7c4;p=perl%2Fmodules%2FVariable-Magic.git Empty the global pointer table at the end of a thread --- diff --git a/Magic.xs b/Magic.xs index 5a46c64..caff817 100644 --- a/Magic.xs +++ b/Magic.xs @@ -490,6 +490,22 @@ STATIC void vmg_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) { ptable_store(ud->wizards, ent->key, w); } +STATIC void vmg_thread_cleanup(pTHX_ void *); + +STATIC void vmg_thread_cleanup(pTHX_ void *ud) { + int *level = ud; + + if (*level) { + --*level; + LEAVE; + SAVEDESTRUCTOR_X(vmg_thread_cleanup, level); + ENTER; + } else { + dMY_CXT; + PerlMemShared_free(level); + ptable_free(MY_CXT.wizards); + } +} #endif /* VMG_THREADSAFE */ /* --- Wizard objects ------------------------------------------------------ */ @@ -1294,7 +1310,6 @@ CLONE(...) PROTOTYPE: DISABLE PREINIT: ptable *t; - int *level; U32 had_b__op_stash = 0; opclass c; PPCODE: @@ -1320,6 +1335,14 @@ PPCODE: ? gv_stashpv(vmg_opclassnames[c], 1) : NULL; } } + { + int *level; + level = PerlMemShared_malloc(sizeof *level); + *level = 1; + LEAVE; + SAVEDESTRUCTOR_X(vmg_thread_cleanup, level); + ENTER; + } XSRETURN(0); #endif /* VMG_THREADSAFE */