Author: joes
Date: Wed Mar  2 15:14:28 2005
New Revision: 155973

URL: http://svn.apache.org/viewcvs?view=rev&rev=155973
Log:

If $r->document_root was modified, restore it at the end of request.

Reviewed by: joes
Written by: stas

Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/t/response/TestModperl/setupenv.pm
    perl/modperl/trunk/todo/release
    perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h

Modified: perl/modperl/trunk/Changes
URL: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?view=diff&r1=155972&r2=155973
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Wed Mar  2 15:14:28 2005
@@ -12,6 +12,9 @@
 
 =item 1.999_22-dev
 
+if $r->document_root was modified, restore it at the end of request
+[joes]
+
 Apache::ServerRec method which set the non-integer fields in the
 server_rec, now copy the value from the perl scalar, so if it changes
 or goes out of scope the C struct is not affected. Using internal perl

Modified: perl/modperl/trunk/t/response/TestModperl/setupenv.pm
URL: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestModperl/setupenv.pm?view=diff&r1=155972&r2=155973
==============================================================================
--- perl/modperl/trunk/t/response/TestModperl/setupenv.pm (original)
+++ perl/modperl/trunk/t/response/TestModperl/setupenv.pm Wed Mar  2 15:14:28 
2005
@@ -181,7 +181,7 @@
 
     KeepAlive On
 
-    <IfDefine PERL_USEITHREADS>
+    <IfDefine PERL_ITHREADS>
         PerlInterpScope connection
     </Ifdefine>
 

Modified: perl/modperl/trunk/todo/release
URL: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/todo/release?view=diff&r1=155972&r2=155973
==============================================================================
--- perl/modperl/trunk/todo/release (original)
+++ perl/modperl/trunk/todo/release Wed Mar  2 15:14:28 2005
@@ -4,7 +4,3 @@
 
 -- see also todo/api_status
 -- see also todo/release-checklist
-
-* document_root needs to be restored at the end of request
-  http://marc.theaimsgroup.com/?t=110842294700006&r=1&w=2
-  owner: joes

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&r1=155972&r2=155973
==============================================================================
--- perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h (original)
+++ perl/modperl/trunk/xs/Apache/RequestUtil/Apache__RequestUtil.h Wed Mar  2 
15:14:28 2005
@@ -309,6 +309,21 @@
     }
 }
 
+/* in order to ensure that s->document_root doesn't get corrupted by
+ * modperl users setting its value, restore the original value at the
+ * end of each request */
+struct mp_docroot_info {
+    const char **docroot;
+    const char *original;
+};
+
+static apr_status_t restore_docroot(void *data)
+{
+    struct mp_docroot_info *di = (struct mp_docroot_info *)data;
+    *di->docroot  = di->original;
+    return APR_SUCCESS;
+}
+
 static MP_INLINE
 const char *mpxs_Apache__RequestRec_document_root(pTHX_ request_rec *r,
                                                   SV *new_root)
@@ -316,10 +331,17 @@
     const char *retval = ap_document_root(r);
 
     if (new_root) {
+        struct mp_docroot_info *di;
         core_server_config *conf;
         MP_CROAK_IF_THREADS_STARTED("setting $r->document_root");
         conf = ap_get_module_config(r->server->module_config, 
                                     &core_module);
+        di = apr_palloc(r->pool, sizeof *di);
+        di->docroot = &conf->ap_document_root;
+        di->original = conf->ap_document_root;
+        apr_pool_cleanup_register(r->pool, di, restore_docroot,
+                                  restore_docroot);
+
         conf->ap_document_root = apr_pstrdup(r->pool, SvPV_nolen(new_root));
     }
 


Reply via email to