stas 2004/02/09 11:05:59
Modified: xs/Apache/RequestRec Apache__RequestRec.h xs/maps apache_structures.map modperl_functions.map xs/tables/current/ModPerl FunctionTable.pm . Changes Log: when $r->handler($new_handler) is called from a response phase, it now checks that the response handler type is not switched (e.g. from 'modperl' to 'perl-script') from the currently used one Revision Changes Path 1.10 +49 -0 modperl-2.0/xs/Apache/RequestRec/Apache__RequestRec.h Index: Apache__RequestRec.h =================================================================== RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestRec/Apache__RequestRec.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -u -r1.9 -r1.10 --- Apache__RequestRec.h 30 Jan 2004 18:20:10 -0000 1.9 +++ Apache__RequestRec.h 9 Feb 2004 19:05:59 -0000 1.10 @@ -70,3 +70,52 @@ #define mpxs_Apache__RequestRec_server_root_relative(sv, fname) \ modperl_server_root_relative(aTHX_ sv, fname) +static MP_INLINE +const char *mpxs_Apache__RequestRec_handler(pTHX_ I32 items, + SV **MARK, SV **SP) +{ + const char *RETVAL; + request_rec *r; + mpxs_usage_va_1(r, "$r->handler([$handler])"); + + RETVAL = (const char *)r->handler; + + if (items == 2) { + if (SvPOK(*MARK)) { + char *new_handler = SvPVX(*MARK); + /* once inside a response phase, one should not try to + * switch response handler types, since they won't take + * any affect */ + if (strEQ(modperl_callback_current_callback_get(), + "PerlResponseHandler")) { + + switch (*new_handler) { + case 'm': + if (strEQ(new_handler, "modperl") && + strEQ(RETVAL, "perl-script")) { + Perl_croak(aTHX_ "Can't switch from 'perl-script' " + "to 'modperl' response handler"); + } + break; + case 'p': + if (strEQ(new_handler, "perl-script") && + strEQ(RETVAL, "modperl")) { + Perl_croak(aTHX_ "Can't switch from 'modperl' " + "to 'perl-script' response handler"); + } + break; + } + } + + r->handler = (const char *)apr_pstrmemdup( + mpxs_Apache__RequestRec_pool(r), new_handler, SvLEN(*MARK)); + } + else { + Perl_croak(aTHX_ "the new_handler argument must be a string"); + } + } + + return RETVAL; +} + + 1.20 +1 -1 modperl-2.0/xs/maps/apache_structures.map Index: apache_structures.map =================================================================== RCS file: /home/cvs/modperl-2.0/xs/maps/apache_structures.map,v retrieving revision 1.19 retrieving revision 1.20 diff -u -u -r1.19 -r1.20 --- apache_structures.map 19 Feb 2003 14:12:02 -0000 1.19 +++ apache_structures.map 9 Feb 2004 19:05:59 -0000 1.20 @@ -41,7 +41,7 @@ ~ subprocess_env notes ~ content_type - handler +~ handler content_encoding content_languages > vlist_validator 1.69 +2 -0 modperl-2.0/xs/maps/modperl_functions.map Index: modperl_functions.map =================================================================== RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v retrieving revision 1.68 retrieving revision 1.69 diff -u -u -r1.68 -r1.69 --- modperl_functions.map 22 Jan 2004 23:25:54 -0000 1.68 +++ modperl_functions.map 9 Feb 2004 19:05:59 -0000 1.69 @@ -17,6 +17,8 @@ mpxs_Apache__RequestRec_subprocess_env | | r, key=NULL, val=Nullsv mpxs_Apache__RequestRec_finfo SV *:DEFINE_server_root_relative | | SV *:p, const char *:fname="" + mpxs_Apache__RequestRec_handler | | ... + MODULE=Apache::RequestUtil PACKAGE=guess mpxs_Apache__RequestRec_push_handlers 1.144 +26 -0 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm Index: FunctionTable.pm =================================================================== RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.143 retrieving revision 1.144 diff -u -u -r1.143 -r1.144 --- FunctionTable.pm 31 Jan 2004 10:06:59 -0000 1.143 +++ FunctionTable.pm 9 Feb 2004 19:05:59 -0000 1.144 @@ -6185,6 +6185,32 @@ ] }, { + 'return_type' => 'const char *', + 'name' => 'mpxs_Apache__RequestRec_handler', + 'attr' => [ + 'static', + '__inline__' + ], + 'args' => [ + { + 'type' => 'PerlInterpreter *', + 'name' => 'my_perl' + }, + { + 'type' => 'I32', + 'name' => 'items' + }, + { + 'type' => 'SV **', + 'name' => 'mark' + }, + { + 'type' => 'SV **', + 'name' => 'sp' + } + ] + }, + { 'return_type' => 'void', 'name' => 'mpxs_ap_allow_methods', 'args' => [ 1.322 +4 -0 modperl-2.0/Changes Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.321 retrieving revision 1.322 diff -u -u -r1.321 -r1.322 --- Changes 9 Feb 2004 18:44:43 -0000 1.321 +++ Changes 9 Feb 2004 19:05:59 -0000 1.322 @@ -12,6 +12,10 @@ =item 1.99_13-dev +when $r->handler($new_handler) is called from a response phase, it now +checks that the response handler type is not switched (e.g. from +'modperl' to 'perl-script') from the currently used one [Stas] + Since Apache::SubProcess is now part of the mp2 API, add $r->cleanup_for_exec as a noop in Apache::compat. That function is no longer needed in Apache2. [Stas]