Author: gozer Date: Fri Dec 3 22:12:20 2004 New Revision: 109781 URL: http://svn.apache.org/viewcvs?view=rev&rev=109781 Log: Apache::RequestUtil : $r->child_terminate() implemented for non-threaded MPMs.
Modified: perl/modperl/trunk/Changes perl/modperl/trunk/src/modules/perl/mod_perl.h perl/modperl/trunk/t/response/TestAPI/request_util.pm perl/modperl/trunk/todo/features_missing perl/modperl/trunk/todo/release perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h perl/modperl/trunk/xs/maps/modperl_functions.map perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm Modified: perl/modperl/trunk/Changes Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?view=diff&rev=109781&p1=perl/modperl/trunk/Changes&r1=109780&p2=perl/modperl/trunk/Changes&r2=109781 ============================================================================== --- perl/modperl/trunk/Changes (original) +++ perl/modperl/trunk/Changes Fri Dec 3 22:12:20 2004 @@ -12,6 +12,9 @@ =item 1.99_18-dev +Apache::RequestUtil : $r->child_terminate() implemented for +non-threaded MPMs. [Gozer] + new API Apache::ServerUtil::restart_count() which can be used to tell whether the server is starting/restarting/gracefully restarting/etc. Based on this feature implement Modified: perl/modperl/trunk/src/modules/perl/mod_perl.h Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/mod_perl.h?view=diff&rev=109781&p1=perl/modperl/trunk/src/modules/perl/mod_perl.h&r1=109780&p2=perl/modperl/trunk/src/modules/perl/mod_perl.h&r2=109781 ============================================================================== --- perl/modperl/trunk/src/modules/perl/mod_perl.h (original) +++ perl/modperl/trunk/src/modules/perl/mod_perl.h Fri Dec 3 22:12:20 2004 @@ -101,7 +101,13 @@ Perl_croak(aTHX_ "Can't run '%s' in the threaded " \ "environment after server startup", what); \ } - + +#define MP_CROAK_IF_THREADED_MPM(what) \ + if (modperl_threaded_mpm()) { \ + Perl_croak(aTHX_ "Can't run '%s' in a threaded mpm", \ + what); \ + } + int modperl_init_vhost(server_rec *s, apr_pool_t *p, server_rec *base_server); void modperl_init(server_rec *s, apr_pool_t *p); Modified: perl/modperl/trunk/t/response/TestAPI/request_util.pm Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestAPI/request_util.pm?view=diff&rev=109781&p1=perl/modperl/trunk/t/response/TestAPI/request_util.pm&r1=109780&p2=perl/modperl/trunk/t/response/TestAPI/request_util.pm&r2=109781 ============================================================================== --- perl/modperl/trunk/t/response/TestAPI/request_util.pm (original) +++ perl/modperl/trunk/t/response/TestAPI/request_util.pm Fri Dec 3 22:12:20 2004 @@ -20,7 +20,7 @@ sub handler { my $r = shift; - plan $r, tests => (scalar keys %status_lines) + 10; + plan $r, tests => (scalar keys %status_lines) + 11; ok $r->default_type; @@ -63,6 +63,14 @@ ok t_cmp(Apache::RequestUtil::get_status_line($code), $line, "Apache::RequestUtil::get_status_line($code)"); + } + + if (Apache::MPM->is_threaded) { + eval { $r->child_terminate() }; + ok t_cmp($@, qr/Can't run.*in a threaded mpm/, "child_terminate"); + } + else { + ok $r->child_terminate() || 1; } Apache::OK; Modified: perl/modperl/trunk/todo/features_missing Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/todo/features_missing?view=diff&rev=109781&p1=perl/modperl/trunk/todo/features_missing&r1=109780&p2=perl/modperl/trunk/todo/features_missing&r2=109781 ============================================================================== --- perl/modperl/trunk/todo/features_missing (original) +++ perl/modperl/trunk/todo/features_missing Fri Dec 3 22:12:20 2004 @@ -11,6 +11,13 @@ - Automatic setting of cmd_args in @APACHE_MODULE_DIRECTIVE based on function prototype +* $r->child_terminate: + - Apache has no API for this (used to be ap_child_terminate). The + current solution is not ideal. Better trying to get ap_child_terminate + back in the httpd API. + - future ideas for threaded mpms: might consider knocking + off the current PerlInterpreter instead. + * tied filehandle interface: -EOF, TELL, SEEK -READLINE - proper implementation (see comment in Apache::compat) Modified: perl/modperl/trunk/todo/release Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/todo/release?view=diff&rev=109781&p1=perl/modperl/trunk/todo/release&r1=109780&p2=perl/modperl/trunk/todo/release&r2=109781 ============================================================================== --- perl/modperl/trunk/todo/release (original) +++ perl/modperl/trunk/todo/release Fri Dec 3 22:12:20 2004 @@ -4,22 +4,6 @@ -- see also todo/api_status -* $r->child_terminate: - - a must to be able to port Apache::SizeLimit, which is a - showstopper for many mp1 users wanting to move to mp2. - - since apache has no API implement as a cleanup handler that calls - exit(0) - - since it's possible that there are other cleanup handlers - registered after, see if it's possible to register another - function when this cleanup handler is called, which will actually - call exit (which hopefully makes sure that this cleanup handler is - always running last). - - it should die if called within the threaded mpm, after the - post_config phase. - - future ideas for threaded mpms: might consider knocking - off the current PerlInterpreter instead. - owner: gozer - * pools that go out of scope: perl -MApache2 -MAPR::Pool -MAPR::PerlIO -le '; Modified: perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h?view=diff&rev=109781&p1=perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h&r1=109780&p2=perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h&r2=109781 ============================================================================== --- perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h (original) +++ perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h Fri Dec 3 22:12:20 2004 @@ -315,3 +315,25 @@ return retval; } + +static apr_status_t child_terminate(void *data) { + apr_pool_t *pool = (apr_pool_t *)data; + + /* On the first pass, re-register so we end up last */ + if (data) { + apr_pool_cleanup_register(pool, NULL, child_terminate, + apr_pool_cleanup_null); + } + else { + exit(0); + } + return APR_SUCCESS; +} + +static MP_INLINE +void mpxs_Apache__RequestRec_child_terminate(pTHX_ request_rec *r) +{ + MP_CROAK_IF_THREADED_MPM("$r->child_terminate") + apr_pool_cleanup_register(r->pool, r->pool, child_terminate, + apr_pool_cleanup_null); +} Modified: perl/modperl/trunk/xs/maps/modperl_functions.map Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/maps/modperl_functions.map?view=diff&rev=109781&p1=perl/modperl/trunk/xs/maps/modperl_functions.map&r1=109780&p2=perl/modperl/trunk/xs/maps/modperl_functions.map&r2=109781 ============================================================================== --- perl/modperl/trunk/xs/maps/modperl_functions.map (original) +++ perl/modperl/trunk/xs/maps/modperl_functions.map Fri Dec 3 22:12:20 2004 @@ -32,6 +32,7 @@ mpxs_Apache__RequestRec_pnotes | | r, key=Nullsv, val=Nullsv mpxs_Apache__RequestRec_add_config | | r, lines, override=OR_AUTHCFG mpxs_Apache__RequestRec_document_root | | r, new_root=Nullsv + mpxs_Apache__RequestRec_child_terminate #protocol module helpers mpxs_Apache__RequestRec_location_merge Modified: perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm?view=diff&rev=109781&p1=perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm&r1=109780&p2=perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm&r2=109781 ============================================================================== --- perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm (original) +++ perl/modperl/trunk/xs/tables/current/ModPerl/FunctionTable.pm Fri Dec 3 22:12:20 2004 @@ -6510,6 +6510,20 @@ ] }, { + 'return_type' => 'void', + 'name' => 'mpxs_Apache__RequestRec_child_terminate', + 'args' => [ + { + 'type' => 'PerlInterpreter *', + 'name' => 'my_perl' + }, + { + 'type' => 'request_rec *', + 'name' => 'r' + } + ] + }, + { 'return_type' => 'SV *', 'name' => 'mpxs_Apache__RequestRec_content_languages', 'args' => [