Stas Bekman wrote:
[...]
SV *server_admin = perl_get_sv("Apache::ServerRec::ServerAdmin", TRUE);
sv_setsv(server_admin, ST(1));
obj->server_admin = SvPVX(serever_admin);
i.e. we create a superficial perl variable to make sure that the value
will stick around if the original scalar is modified or destroyed.
So the fields that need a fixup are:
Apache::ServerRec: (all autogenerated)
server_admin
server_hostname
error_fname
path
names
wild_names
the following 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
And here is the patch:
Index: xs/maps/apache_structures.map
===================================================================
--- xs/maps/apache_structures.map (revision 155373)
+++ xs/maps/apache_structures.map (working copy)
@@ -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
Index: lib/ModPerl/MapUtil.pm
===================================================================
--- lib/ModPerl/MapUtil.pm (revision 155373)
+++ lib/ModPerl/MapUtil.pm (working copy)
@@ -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',
Index: lib/ModPerl/WrapXS.pm
===================================================================
--- lib/ModPerl/WrapXS.pm (revision 155376)
+++ lib/ModPerl/WrapXS.pm (working copy)
@@ -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";
Index: lib/ModPerl/StructureMap.pm
===================================================================
--- lib/ModPerl/StructureMap.pm (revision 155373)
+++ lib/ModPerl/StructureMap.pm (working copy)
@@ -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;
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]