You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2004/12/22 21:27:10 UTC
exit and ModPerl::Util::exit
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...
--Geoff
Re: exit and ModPerl::Util::exit
Posted by Stas Bekman <st...@stason.org>.
the 3rd solution is now committed.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>You don't need to import it. We did that in mp1, in mp2 we do:
>>
>>*CORE::GLOBAL::exit = \&ModPerl::Util::exit.
>>
>>but in C.
>
>
> yah, ok.
>
> for the record, I have no idea why the other exit() call in Apache/Test.pm
> ends up working, but I suppose it's not important :)
It works under mp2 because of the above.
It shouldn't work under mp1 and needs to be fixed. I guess you've meant that.
> anyway, have a nice holiday everyone :)
What holidays? Ah, right, something about jesus... Have a happy one :)
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> You don't need to import it. We did that in mp1, in mp2 we do:
>
> *CORE::GLOBAL::exit = \&ModPerl::Util::exit.
>
> but in C.
yah, ok.
for the record, I have no idea why the other exit() call in Apache/Test.pm
ends up working, but I suppose it's not important :)
anyway, have a nice holiday everyone :)
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>>you wouldn't want to just import the namespaces required during
>>>modperl_perl_core_global_init?
>>
>>
>>Sorry, Geoff, I don't understand what do you ask. You talk about the 3rd
>>solution?
>
>
> well, kinda. isn't the issue that ModPerl::Util isn't imported? I mean,
> clearly ModPerl::Util::exit has been defined, but the module as a whole
> hasn't been use()d yet.
You don't need to import it. We did that in mp1, in mp2 we do:
*CORE::GLOBAL::exit = \&ModPerl::Util::exit.
but in C.
>so, something like this
>
> typedef struct {
> const char *name;
> const char *package;
> const char *sub_name;
> const char *core_name;
> } modperl_perl_core_global_t;
>
> while (cglobals->name) {
> [code that requires cglobals->package]
> GV *gv = gv_fetchpv(cglobals->core_name, TRUE, SVt_PVCV);
> GvCV(gv) = get_cv(cglobals->sub_name, TRUE);
> GvIMPORTED_CV_on(gv);
> cglobals++;
> }
>
> I would think would be sufficient, rather than moving the entire
> ModPerl::Util class into core.
we don't do that. You still need to load ModPerl::Util to get the other
functions. It's just that we choose that exit() belongs to that namespace,
but it doesn't live in the XS module anymore.
> but my brain has been on another planet
> recently, so don't let me stop your progress or pull you into a
> time-straining discussion if I'm not correct. just go with what you and
> philippe think is best.
:)
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> you wouldn't want to just import the namespaces required during
>> modperl_perl_core_global_init?
>
>
> Sorry, Geoff, I don't understand what do you ask. You talk about the 3rd
> solution?
well, kinda. isn't the issue that ModPerl::Util isn't imported? I mean,
clearly ModPerl::Util::exit has been defined, but the module as a whole
hasn't been use()d yet. so, something like this
typedef struct {
const char *name;
const char *package;
const char *sub_name;
const char *core_name;
} modperl_perl_core_global_t;
while (cglobals->name) {
[code that requires cglobals->package]
GV *gv = gv_fetchpv(cglobals->core_name, TRUE, SVt_PVCV);
GvCV(gv) = get_cv(cglobals->sub_name, TRUE);
GvIMPORTED_CV_on(gv);
cglobals++;
}
I would think would be sufficient, rather than moving the entire
ModPerl::Util class into core. but my brain has been on another planet
recently, so don't let me stop your progress or pull you into a
time-straining discussion if I'm not correct. just go with what you and
philippe think is best.
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>
> Stas Bekman wrote:
>
>>Geoffrey Young wrote:
>>
>>
>>>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.
>
>
> you wouldn't want to just import the namespaces required during
> modperl_perl_core_global_init?
Sorry, Geoff, I don't understand what do you ask. You talk about the 3rd
solution?
> other than that, whatever you guys feel is best is fine with me.
>
> --Geoff
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Stas Bekman wrote:
> Geoffrey Young wrote:
>
>> 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.
you wouldn't want to just import the namespaces required during
modperl_perl_core_global_init?
other than that, whatever you guys feel is best is fine with me.
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: exit and ModPerl::Util::exit
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 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);
#endif
2) 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:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org