hi all...
it seems you can't call exit from a handler unless ModPerl::Util::exit has been preloaded. the attached tarball reproduces, but it's impossible (well, difficult) to prove from the mp2 test suite with all it's preloading...
I have 3 solutions. Thanks to Philippe for helping me with the 3rd one. Philippe and I tend to think that the 3rd solution is the best.
1) move the CORE:: overrides to the post_config_last phase and preload ModPerl::Util there (drawback, may need to override other CORE:: things later at an earlier stage.
Index: src/modules/perl/mod_perl.c =================================================================== --- src/modules/perl/mod_perl.c (revision 123029) +++ src/modules/perl/mod_perl.c (working copy) @@ -102,8 +102,6 @@
modperl_env_configure_server(aTHX_ p, s);
- modperl_perl_core_global_init(aTHX);
-
for (i=0; MP_xs_loaders[i]; i++) {
char *name = Perl_form(aTHX_ MP_xs_loader_name, MP_xs_loaders[i]);
newCONSTSUB(PL_defstash, name, newSViv(1));
@@ -701,6 +699,13 @@
modperl_mgv_hash_handlers(pconf, s);
modperl_modglobal_hash_keys(aTHX);
modperl_env_hash_keys(aTHX);
+
+ modperl_require_module(aTHX_ "ModPerl::Util", TRUE);
+ /* at the moment overriding CORE::exit at the end of post_config
+ * phase, since we need to load ModPerl::Util first, which can't
+ * be done before user manipulates @INC */
+ modperl_perl_core_global_init(aTHX);
+
#ifdef USE_ITHREADS
modperl_init_clones(s, pconf);
#endif2) AUTOLOAD hack (having some problem with
Attempt to free unreferenced scalar: SV 0x8181bac, Perl interpreter: 0x8160428 at (null) line 1.
in geoff's tarball)
Index: src/modules/perl/modperl_perl.c
===================================================================
--- src/modules/perl/modperl_perl.c (revision 123029)
+++ src/modules/perl/modperl_perl.c (working copy)
@@ -36,13 +36,27 @@
void modperl_perl_core_global_init(pTHX)
{
modperl_perl_core_global_t *cglobals = MP_perl_core_global_entries;
-
+
while (cglobals->name) {
GV *gv = gv_fetchpv(cglobals->core_name, TRUE, SVt_PVCV);
GvCV(gv) = get_cv(cglobals->sub_name, TRUE);
GvIMPORTED_CV_on(gv);
cglobals++;
}
+
+ ENTER;SAVETMPS;
+ Perl_eval_pv(aTHX_
+"package ModPerl::Util; *AUTOLOAD = sub {"
+" (my $method = $ModPerl::Util::AUTOLOAD) =~ s/.*:://;"
+" if ($method eq 'exit') {"
+" require ModPerl::Util;"
+" goto &$ModPerl::Util::AUTOLOAD;"
+" }"
+" else {"
+" die qq[no such method: $ModPerl::Util::AUTOLOAD];"
+" }"
+ "}; package main;", TRUE);
+ FREETMPS;LEAVE;
}static void modperl_perl_ids_get(modperl_perl_ids_t *ids)
3) move ModPerl::Util::exit into the core, so that function will be available w/o requiring loading ModPerl::Util
Index: src/modules/perl/modperl_perl.c
===================================================================
--- src/modules/perl/modperl_perl.c (revision 123029)
+++ src/modules/perl/modperl_perl.c (working copy)
@@ -33,16 +33,36 @@
{ NULL },
};+XS(XS_ModPerl__Util_exit); /* prototype to pass -Wmissing-prototypes */
+XS(XS_ModPerl__Util_exit)
+{
+ dXSARGS;
+ int status;
+ if (items < 0 || items > 1) {
+ Perl_croak(aTHX_ "Usage: ModPerl::Util::exit(status=0)");
+ }
+ if (items < 1)
+ status = 0; /* default: 0 */
+ else {
+ status = (int)SvIV(ST(0));
+ }
+ modperl_perl_exit(aTHX_ status);
+
+ XSRETURN_EMPTY;
+}
+
void modperl_perl_core_global_init(pTHX)
{
modperl_perl_core_global_t *cglobals = MP_perl_core_global_entries;
-
+
while (cglobals->name) {
GV *gv = gv_fetchpv(cglobals->core_name, TRUE, SVt_PVCV);
GvCV(gv) = get_cv(cglobals->sub_name, TRUE);
GvIMPORTED_CV_on(gv);
cglobals++;
}
+
+ newXS("ModPerl::Util::exit", XS_ModPerl__Util_exit, __FILE__);
}static void modperl_perl_ids_get(modperl_perl_ids_t *ids)
Index: xs/maps/modperl_functions.map =================================================================== --- xs/maps/modperl_functions.map (revision 123029) +++ xs/maps/modperl_functions.map (working copy) @@ -6,7 +6,6 @@ MODULE=ModPerl::Util mpxs_ModPerl__Util_untaint | | ... SV *:DEFINE_current_perl_id - DEFINE_exit | | int:status=0 char *:DEFINE_current_callback DEFINE_unload_package | | const char *:package
Index: xs/ModPerl/Util/ModPerl__Util.h
===================================================================
--- xs/ModPerl/Util/ModPerl__Util.h (revision 123029)
+++ xs/ModPerl/Util/ModPerl__Util.h (working copy)
@@ -32,8 +32,6 @@
}
}-#define mpxs_ModPerl__Util_exit(status) modperl_perl_exit(aTHX_ status)
-
#define mpxs_ModPerl__Util_current_callback \
modperl_callback_current_callback_get
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
