This patch makes the document_root read/write for non-threaded MPMs, since it's
unsafe to do so with threaded MPMs until httpd stores the document root elsewhere
than in the server configuration structure.

--
--------------------------------------------------------------------------------
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: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.505
diff -u -I$Id -r1.505 Changes
--- Changes	30 Sep 2004 03:39:24 -0000	1.505
+++ Changes	30 Sep 2004 21:15:57 -0000
@@ -12,6 +12,8 @@
 
 =item 1.99_17-dev
 
+$r->document_root can now be changed in non-threaded MPMs [Gozer]
+
 tag the custom pools created by mod_perl for easier pools debug [Joe
 Orton]
 
Index: t/response/TestAPI/request_util.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/request_util.pm,v
retrieving revision 1.1
diff -u -I$Id -r1.1 request_util.pm
--- t/response/TestAPI/request_util.pm	15 Jul 2004 21:35:48 -0000	1.1
+++ t/response/TestAPI/request_util.pm	30 Sep 2004 21:15:57 -0000
@@ -7,6 +7,7 @@
 use Apache::TestUtil;
 
 use Apache::RequestUtil ();
+use Apache::MPM ();
 
 use Apache::Const -compile => 'OK';
 
@@ -19,12 +20,24 @@
 sub handler {
     my $r = shift;
 
-    plan $r, tests => (scalar keys %status_lines) + 8;
+    plan $r, tests => (scalar keys %status_lines) + 10;
 
     ok $r->default_type;
 
-    ok $r->document_root;
+    my $document_root = $r->document_root;
 
+    ok $document_root;
+    
+    if (!Apache::MPM->is_threaded) {
+        ok t_cmp($document_root, $r->document_root('/tmp/foo'));
+    
+        ok t_cmp('/tmp/foo', $r->document_root($document_root));
+    }
+    else {
+        ok 1;
+        ok 1;
+    }
+    
     ok $r->get_server_name;
 
     ok $r->get_server_port;
Index: todo/release
===================================================================
RCS file: /home/cvs/modperl-2.0/todo/release,v
retrieving revision 1.64
diff -u -I$Id -r1.64 release
--- todo/release	24 Sep 2004 19:55:35 -0000	1.64
+++ todo/release	30 Sep 2004 21:15:57 -0000
@@ -9,13 +9,6 @@
   will know exactly once libapr is fixed
   owner: stas
 
-* $r->document_root:
-  cannot currently be modified.  requires locking since it is part of
-  the per-server config structure which is shared between threads
-  but even w/o locking one thread is not allowed to affect other
-  threads with this change, so it's out of question to make this
-  method set-able for threaded after the startup item
-
 * $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.
Index: xs/Apache/RequestUtil/Apache__RequestUtil.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestUtil/Apache__RequestUtil.h,v
retrieving revision 1.25
diff -u -I$Id -r1.25 Apache__RequestUtil.h
--- xs/Apache/RequestUtil/Apache__RequestUtil.h	18 Aug 2004 05:52:22 -0000	1.25
+++ xs/Apache/RequestUtil/Apache__RequestUtil.h	30 Sep 2004 21:15:57 -0000
@@ -299,3 +299,19 @@
     }
 }
 
+static MP_INLINE
+const char *mpxs_Apache__RequestRec_document_root(pTHX_ request_rec *r,
+                                                  SV *new_root)
+{
+    const char *retval = ap_document_root(r);
+    
+    if (new_root) {
+        MP_CROAK_IF_THREADS_STARTED("setting $r->document_root");
+        core_server_config *conf = 
+            ap_get_module_config(r->server->module_config, 
+                                 &core_module);
+        conf->ap_document_root = SvPV_nolen(new_root);
+    }
+
+    return retval;
+}
Index: xs/maps/apache_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v
retrieving revision 1.104
diff -u -I$Id -r1.104 apache_functions.map
--- xs/maps/apache_functions.map	17 Sep 2004 00:07:24 -0000	1.104
+++ xs/maps/apache_functions.map	30 Sep 2004 21:15:57 -0000
@@ -55,7 +55,7 @@
 ~ap_set_content_type
 
 #MODULE=Apache::RequestConfig
- ap_document_root
+~ap_document_root
  ap_get_limit_req_body
 ?ap_get_limit_xml_body
 >ap_core_translate
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.89
diff -u -I$Id -r1.89 modperl_functions.map
--- xs/maps/modperl_functions.map	24 Sep 2004 19:55:35 -0000	1.89
+++ xs/maps/modperl_functions.map	30 Sep 2004 21:15:57 -0000
@@ -31,6 +31,7 @@
  mpxs_Apache__RequestRec_as_string
  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
 
  #protocol module helpers
  mpxs_Apache__RequestRec_location_merge
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.185
diff -u -I$Id -r1.185 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm	22 Sep 2004 23:22:07 -0000	1.185
+++ xs/tables/current/ModPerl/FunctionTable.pm	30 Sep 2004 21:15:57 -0000
@@ -1,8 +1,8 @@
 package ModPerl::FunctionTable;
 
 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-# ! WARNING: generated by ModPerl::ParseSource/0.010
-# !          Wed Sep 22 14:01:12 2004
+# ! WARNING: generated by ModPerl::ParseSource/0.01
+# !          Wed Sep 29 16:02:04 2004
 # !          do NOT edit, any changes will be lost !
 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -6404,6 +6404,24 @@
       {
         'type' => 'SV *',
         'name' => 'type'
+      }
+    ]
+  },
+  {
+    'return_type' => 'const char *',
+    'name' => 'mpxs_Apache__RequestRec_document_root',
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+      {
+        'type' => 'request_rec *',
+        'name' => 'r'
+      },
+      {
+        'type' => 'SV *',
+        'name' => 'new_root'
       }
     ]
   },

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to