Author: stas
Date: Tue Mar 1 19:32:35 2005
New Revision: 155863
URL: http://svn.apache.org/viewcvs?view=rev&rev=155863
Log:
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
variables to preserve the value, since using the server pool to
allocate the memory will mean a memory leak
Modified:
perl/modperl/trunk/Changes
perl/modperl/trunk/lib/ModPerl/MapUtil.pm
perl/modperl/trunk/lib/ModPerl/StructureMap.pm
perl/modperl/trunk/lib/ModPerl/WrapXS.pm
perl/modperl/trunk/todo/release
perl/modperl/trunk/xs/maps/apache_structures.map
Modified: perl/modperl/trunk/Changes
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Tue Mar 1 19:32:35 2005
@@ -12,6 +12,12 @@
=item 1.999_22-dev
+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
+variables to preserve the value, since using the server pool to
+allocate the memory will mean a memory leak [Stas]
+
add the escape_url entry in the ModPerl::MethodLookup knowledgebase
[Stas]
Modified: perl/modperl/trunk/lib/ModPerl/MapUtil.pm
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/ModPerl/MapUtil.pm?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/lib/ModPerl/MapUtil.pm (original)
+++ perl/modperl/trunk/lib/ModPerl/MapUtil.pm Tue Mar 1 19:32:35 2005
@@ -25,10 +25,13 @@
our @ISA = qw(Exporter);
-# the mapping happens in lib/ModPerl/StructureMap.pm
+# the mapping happens in lib/ModPerl/StructureMap.pm: sub parse
# '<' => 'auto-generated but gives only a read-only access'
# '&' => 'RDWR accessor to a char* field, supporting undef arg'
-# '$' => 'RONLY accessor, with WRITE accessor before child_init'
+# '$' => 'RONLY accessor, with WRITE accessor before child_init'
+# '%' => like $, but makes sure that for the write accessor the
+# original perl scalar can change or go away w/o affecting
+# the object
my %disabled_map = (
'!' => 'disabled or not yet implemented',
'~' => 'implemented but not auto-generated',
Modified: perl/modperl/trunk/lib/ModPerl/StructureMap.pm
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/ModPerl/StructureMap.pm?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/lib/ModPerl/StructureMap.pm (original)
+++ perl/modperl/trunk/lib/ModPerl/StructureMap.pm Tue Mar 1 19:32:35 2005
@@ -128,6 +128,9 @@
elsif ($1 eq '$') {
$map->{$class}->{$_} = 'r+w_startup';
}
+ elsif ($1 eq '%') {
+ $map->{$class}->{$_} = 'r+w_startup_dup';
+ }
}
else {
$map->{$class}->{$_} = undef;
Modified: perl/modperl/trunk/lib/ModPerl/WrapXS.pm
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/ModPerl/WrapXS.pm?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/lib/ModPerl/WrapXS.pm (original)
+++ perl/modperl/trunk/lib/ModPerl/WrapXS.pm Tue Mar 1 19:32:35 2005
@@ -256,6 +256,37 @@
EOF
}
+ elsif ($access_mode eq 'r+w_startup_dup') {
+
+ my $convert = $cast !~ /\bchar\b/
+ ? "mp_xs_sv2_$cast"
+ : "SvPV_nolen";
+
+ $code = <<EOF;
+$type
+$name(obj, val=Nullsv)
+ $class obj
+ SV *val
+
+ PREINIT:
+ $preinit
+$attrs
+
+ CODE:
+ RETVAL = ($cast) obj->$name;
+
+ if (items > 1) {
+ SV *dup = get_sv("_modperl_private::server_rec_$name", TRUE);
+ MP_CROAK_IF_THREADS_STARTED("setting $name");
+ sv_setsv(dup, val);
+ obj->$name = ($cast)$convert(dup);
+ }
+
+ OUTPUT:
+ RETVAL
+
+EOF
+ }
elsif ($access_mode eq 'rw_char_undef') {
my $pool = $e->{pool}
or die "rw_char_undef accessors need pool";
Modified: perl/modperl/trunk/todo/release
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/todo/release?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/todo/release (original)
+++ perl/modperl/trunk/todo/release Tue Mar 1 19:32:35 2005
@@ -8,38 +8,3 @@
* document_root needs to be restored at the end of request
http://marc.theaimsgroup.com/?t=110842294700006&r=1&w=2
owner: joes
-
-* need to review all the API methods that set string values
- (e.g. server_admin) they all assign a pointer to the PV slot in the
- perl scalar and if that scalar goes out of scope or changes, the
- modified data will get corrupted. need to replace
- val = (char *)SvPV_nolen(...);
- with:
- val = apr_pstrdup(pool, (char *)SvPV_nolen(...));
-but the problem with what pool is used is very delicate, for $s
-methods it must be $s->pool and for $r methods, $r->pool, but some $r
-methods try to modify server strings. like document_root, which I've
-started to fix, but it's still broken (not sure what pool should be
-used, $s->pool will mean a memory leak, $r->pool will still mean a
-corrupted data).
-
-Apache::ServerRec: (all autogenerated)
-server_admin
-server_hostname
-error_fname
-path
-names
-wild_names
-
-those are non-pointer assignments (mostly int), so they need no
-backup:
-
-port
-loglevel
-timeout
-keep_alive_timeout
-keep_alive_max
-keep_alive
-limit_req_line
-limit_req_fieldsize
-limit_req_fields
Modified: perl/modperl/trunk/xs/maps/apache_structures.map
URL:
http://svn.apache.org/viewcvs/perl/modperl/trunk/xs/maps/apache_structures.map?view=diff&r1=155862&r2=155863
==============================================================================
--- perl/modperl/trunk/xs/maps/apache_structures.map (original)
+++ perl/modperl/trunk/xs/maps/apache_structures.map Tue Mar 1 19:32:35 2005
@@ -76,10 +76,10 @@
< next
- defn_name
- defn_line_number
-$ server_admin
-$ server_hostname
+% server_admin
+% server_hostname
$ port
-$ error_fname
+% error_fname
$ error_log
$ loglevel
< is_virtual
@@ -90,10 +90,10 @@
$ keep_alive_timeout
$ keep_alive_max
$ keep_alive
-$ path
+% path
- pathlen
-$ names
-$ wild_names
+% names
+% wild_names
$ limit_req_line
$ limit_req_fieldsize
$ limit_req_fields