gozer 2004/10/25 14:57:17
Modified: . Changes src/modules/perl modperl_util.c todo release Log: Fix Modperl::Util::unload_package() [Gozer] - Mistakenly skipping small entries of size 2 and less - Leave entries from other packages alone Revision Changes Path 1.517 +4 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.516 retrieving revision 1.517 diff -u -r1.516 -r1.517 --- Changes 22 Oct 2004 21:49:46 -0000 1.516 +++ Changes 25 Oct 2004 21:57:17 -0000 1.517 @@ -12,6 +12,10 @@ =item 1.99_18-dev +Fix Modperl::Util::unload_package() [Gozer] + - Mistakenly skipping small entries of size 2 and less + - Leave entries from other packages alone + =item 1.99_17 - October 22, 2004 Implement Apache->unescape_url_info in Apache::compat and drop it 1.85 +18 -3 modperl-2.0/src/modules/perl/modperl_util.c Index: modperl_util.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v retrieving revision 1.84 retrieving revision 1.85 diff -u -r1.84 -r1.85 --- modperl_util.c 14 Oct 2004 18:25:01 -0000 1.84 +++ modperl_util.c 25 Oct 2004 21:57:17 -0000 1.85 @@ -827,6 +827,14 @@ } /* Destroy a package's stash */ +#define MP_STASH_SUBSTASH(key, len) ((len >= 2) && \ + (key[len-1] == ':') && \ + (key[len-2] == ':')) +#define MP_STASH_DEBUGGER(key, len) ((len >= 2) && \ + (key[0] == '_') && \ + (key[1] == '<')) +#define MP_SAFE_STASH(key, len) (!(MP_STASH_SUBSTASH(key,len)|| \ + (MP_STASH_DEBUGGER(key, len)))) static void modperl_package_clear_stash(pTHX_ const char *package) { HV *stash; @@ -837,9 +845,16 @@ hv_iterinit(stash); while ((he = hv_iternext(stash))) { key = hv_iterkey(he, &len); - /* We skip entries ending with ::, they are sub-stashes */ - if (len > 2 && key[len] != ':' && key[len-1] != ':') { - hv_delete(stash, key, len, G_DISCARD); + if (MP_SAFE_STASH(key, len)) { + SV *val = hv_iterval(stash, he); + char *this_stash = HvNAME(GvSTASH(val)); + /* The safe thing to do is to skip over stash entries + * that don't come from the package we are trying to + * unload + */ + if (strcmp(this_stash, package) == 0) { + hv_delete(stash, key, len, G_DISCARD); + } } } } 1.69 +0 -5 modperl-2.0/todo/release Index: release =================================================================== RCS file: /home/cvs/modperl-2.0/todo/release,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- release 24 Oct 2004 04:57:25 -0000 1.68 +++ release 25 Oct 2004 21:57:17 -0000 1.69 @@ -4,11 +4,6 @@ -- see also todo/api_status -* modperl_package_clear_stash() is skipping over any stash entry with - len(name) <= 2 - http://marc.theaimsgroup.com/?t=109687024800002&r=1&w=2 - owner: gozer - * APR::Finfo constants: APR::FILETYPE_* and APR::FILEPROT_* will probably be APR::FTYPE_* and APR::FPROT_* will know exactly once libapr is fixed