Incredibly thorough bug reporting, many thanks.
You correctly identified a leak and can you give the following patch a spin and let me know if it plugs it?
Rici Lake wrote:
On 8-Sep-04, at 5:24 PM, Philippe M. Chiasson wrote:
Could you please post the 2 .htaccess files you've been using ?
[EMAIL PROTECTED]:/usr/local/www/data/foo$ cat .htaccess <perl> $AuthType = "basic"; $AuthName = "foo"; $AuthUserFile = "/usr/local/www/.htpasswd"; $require = "valid-user"; $order = "deny,allow"; $allow = "from all"; $satisfy = "any"; </perl>
[EMAIL PROTECTED]:/usr/local/www/data/foo$ cat .htaccess.plain #<perl> AuthType basic AuthName foo AuthUserFile /usr/local/www/.htpasswd require valid-user order deny,allow allow from all satisfy any #</perl>
Hrm, that's quite odd, as I looked over the code and AFAIK, <Perl> sections
in .htaccess will be running off parms->pool, and in the case of .htaccess
files, that's r->pool. Can you tell me more about how you made the determination
that it was using the pconf ?
Ok.
The handler for <Perl> (in modperl_cmd.c at line 418, MP_CMD_SRV_DECLARE(perl)) appears to use the pool passed to it by the config reader, which should be r->pool in an .htaccess file. But all it does with it is concatenate the lines up to the closing </Perl> directive into a single string, and use that to create a Perl directive which it inserts into the command stream.
So that drops us into MP_CMD_SRV_DECLARE(perldo), immediately following in the same file.
That function, afaics, starts by checking for options that might have been set in the <Perl> directive itself (which it finds in directive->data thanks to the <Perl> directive handler) and if there are none, as in my simple test, uses Apache::PerlSections as the handler and Apache::ReadConfig as the package. It then prepends the original <Perl> section, now in directive->arg, with the package name and executes it, at around line 538. If that all goes well, it does a callback into the handler with modperl_callback.
So, taking a wild guess, I looked in Apache/PerlSections.pm, and indeed that seems to be where the directives are created, by being pushed one at a time into the array $self->directives. Finally self->post_config gets called, and it in turn calls $self->server->add_config with the directives.
According to the mapping in xs/Apache/ServerUtil/Apache__ServerUtil.h, that ought to end up calling modperl_config_insert_server, which is found in modperl_config.c. That function extracts pconf from the server record, and calls modperl_config_insert with it, at which point the configuration directives are fed into the Apache machinery.
Which is why I figured that it was using pconf.
I was actually just trying to figure out why directives were not being placed into the configtree -- the reason is that modperl_config_insert doesn't hook them into the tree. This doesn't matter for .htaccess files; I just happened to notice that the .htaccess code path appeared to be the same as the main config file code path.
So I tested it, and the test seemed to confirm my suspicions.
-- -------------------------------------------------------------------------------- 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: lib/Apache/PerlSections.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/PerlSections.pm,v
retrieving revision 1.7
diff -u -I$Id -r1.7 PerlSections.pm
--- lib/Apache/PerlSections.pm 23 Aug 2004 21:16:27 -0000 1.7
+++ lib/Apache/PerlSections.pm 9 Sep 2004 17:49:47 -0000
@@ -34,7 +34,7 @@
return bless { @args }, ref($package) || $package;
}
-sub server { return shift->{'parms'}->server() }
+sub parms { return shift->{'parms'} }
sub directives { return shift->{'directives'} ||= [] }
sub package { return shift->{'args'}->{'package'} }
@@ -200,7 +200,7 @@
sub post_config {
my($self) = @_;
- my $errmsg = $self->server->add_config($self->directives);
+ my $errmsg = $self->parms->add_config($self->directives);
die $errmsg if $errmsg;
}
Index: src/modules/perl/modperl_config.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v
retrieving revision 1.80
diff -u -I$Id -r1.80 modperl_config.c
--- src/modules/perl/modperl_config.c 6 Jul 2004 22:06:04 -0000 1.80
+++ src/modules/perl/modperl_config.c 9 Sep 2004 17:49:48 -0000
@@ -561,6 +561,20 @@
return errmsg;
}
+const char *modperl_config_insert_parms(pTHX_ cmd_parms *parms,
+ SV *lines)
+{
+ return modperl_config_insert(aTHX_
+ parms->server,
+ parms->pool,
+ parms->temp_pool,
+ parms->override,
+ parms->path,
+ parms->context,
+ lines);
+}
+
+
const char *modperl_config_insert_server(pTHX_ server_rec *s, SV *lines)
{
int override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
Index: src/modules/perl/modperl_config.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.h,v
retrieving revision 1.34
diff -u -I$Id -r1.34 modperl_config.h
--- src/modules/perl/modperl_config.h 6 Jul 2004 22:06:04 -0000 1.34
+++ src/modules/perl/modperl_config.h 9 Sep 2004 17:49:48 -0000
@@ -130,6 +130,9 @@
ap_conf_vector_t *conf,
SV *lines);
+const char *modperl_config_insert_parms(pTHX_ cmd_parms *parms,
+ SV *lines);
+
const char *modperl_config_insert_server(pTHX_ server_rec *s, SV *lines);
const char *modperl_config_insert_request(pTHX_
Index: xs/Apache/CmdParms/Apache__CmdParms.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/CmdParms/Apache__CmdParms.h,v
retrieving revision 1.3
diff -u -I$Id -r1.3 Apache__CmdParms.h
--- xs/Apache/CmdParms/Apache__CmdParms.h 14 Apr 2004 03:41:39 -0000 1.3
+++ xs/Apache/CmdParms/Apache__CmdParms.h 9 Sep 2004 17:49:48 -0000
@@ -26,3 +26,12 @@
return &PL_sv_undef;
}
+
+static MP_INLINE
+void mpxs_Apache__CmdParms_add_config(pTHX_ cmd_parms *parms, SV *lines)
+{
+ const char *errmsg = modperl_config_insert_parms(aTHX_ parms, lines);
+ if (errmsg) {
+ Perl_croak(aTHX_ "$parms->add_config() has failed: %s", errmsg);
+ }
+}
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.85
diff -u -I$Id -r1.85 modperl_functions.map
--- xs/maps/modperl_functions.map 25 Aug 2004 21:51:21 -0000 1.85
+++ xs/maps/modperl_functions.map 9 Sep 2004 17:49:48 -0000
@@ -145,6 +145,7 @@
ap_check_cmd_context
ap_method_is_limited
mpxs_Apache__CmdParms_info
+ mpxs_Apache__CmdParms_add_config
MODULE=Apache::MPM PACKAGE=Apache::MPM BOOT=1
mpxs_Apache__MPM_query
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.177
diff -u -I$Id -r1.177 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm 8 Sep 2004 00:42:02 -0000 1.177
+++ xs/tables/current/ModPerl/FunctionTable.pm 9 Sep 2004 17:49:48 -0000
@@ -2,7 +2,7 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ! WARNING: generated by ModPerl::ParseSource/0.01
-# ! Mon Aug 30 22:40:23 2004
+# ! Thu Sep 9 10:08:16 2004
# ! do NOT edit, any changes will be lost !
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1356,6 +1356,24 @@
},
{
'return_type' => 'const char *',
+ 'name' => 'modperl_config_insert_parms',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'cmd_parms *',
+ 'name' => 'parms'
+ },
+ {
+ 'type' => 'SV *',
+ 'name' => 'lines'
+ }
+ ]
+ },
+ {
+ 'return_type' => 'const char *',
'name' => 'modperl_config_insert_request',
'args' => [
{
@@ -5744,6 +5762,24 @@
{
'type' => 'apr_uri_t *',
'name' => 'apr_uri'
+ }
+ ]
+ },
+ {
+ 'return_type' => 'void',
+ 'name' => 'mpxs_Apache__CmdParms_add_config',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'cmd_parms *',
+ 'name' => 'parms'
+ },
+ {
+ 'type' => 'SV *',
+ 'name' => 'lines'
}
]
},
signature.asc
Description: OpenPGP digital signature
