Following patch add basic (i.e. exit(0)) functionnality for 
$r->child_terminate()

Note that this is an imperfect solution and should be implemented on the httpd
side in the future. I'll try and start discussion on [EMAIL PROTECTED] about 
reviving
ap_child_terminate().

In the meantime, here it is:


-------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: xs/maps/modperl_functions.map
===================================================================
--- xs/maps/modperl_functions.map       (revision 109735)
+++ xs/maps/modperl_functions.map       (working copy)
@@ -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
Index: xs/Apache/RequestUtil/Apache__RequestUtil.h
===================================================================
--- xs/Apache/RequestUtil/Apache__RequestUtil.h (revision 109735)
+++ xs/Apache/RequestUtil/Apache__RequestUtil.h (working copy)
@@ -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_THREADS_STARTED("child terminate")
+    apr_pool_cleanup_register(r->pool, r->pool, child_terminate,
+                              apr_pool_cleanup_null);
+}
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
--- xs/tables/current/ModPerl/FunctionTable.pm  (revision 109735)
+++ xs/tables/current/ModPerl/FunctionTable.pm  (working copy)
@@ -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' => [
Index: todo/features_missing
===================================================================
--- todo/features_missing       (revision 109735)
+++ todo/features_missing       (working copy)
@@ -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)
Index: Changes
===================================================================
--- Changes     (revision 109735)
+++ Changes     (working copy)
@@ -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

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to