Stas Bekman wrote:
Mariano Absatz wrote:

Hi,

I'm having a weird 'problem'... actually, it's just a nuisance, but I'd like to know if
1) it can be solved
2) it's only a nuisance or it could be hidin' something else...


I'm using:
apache httpd 2.0.48 w/mod_perl 1.99.12 (under RedHat linux 7.2 w/stock perl 5.6.1 installed from rpm) and I just started toying around with the <Perl > directive (in order to get VirtualHost data from an LDAP directory).


Everything is working OK, but whenever I use <Perl >, the output of "ps -
ef" changes.

I normally get something like:
root   3634     1  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start
nobody 3635  3634  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start
nobody 3636  3634  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start
nobody 3637  3634  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start
nobody 3638  3634  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start
nobody 3639  3634  0 20:31 ?     00:00:00 /app/apache/bin/httpd -k start

However, as soon as I put a single line between <Perl > and </Perl> (even if the line is empty), I get something like:
root 3738 1 2 20:34 ? 00:00:00 /app/apache/bin/-e -k start

Please try this patch.


Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.206
diff -u -r1.206 mod_perl.c
--- src/modules/perl/mod_perl.c 10 Jan 2004 05:01:04 -0000      1.206
+++ src/modules/perl/mod_perl.c 12 Feb 2004 01:07:55 -0000
@@ -1,5 +1,7 @@
 #include "mod_perl.h"

+static char *MP_ap_server_argv0;
+
 /* make sure that mod_perl won't try to start itself, while it's
  * already starting. If the flag's value is 1 * it's still starting,
  * when it's 2 it is running */
@@ -201,6 +203,17 @@
     status = perl_parse(perl, modperl_xs_init, argc, argv, NULL);
     MP_boot_data_set(NULL, NULL);

+    /* perl doesn't take into an account that it can be embedded and
+     * argv can be longer than the one passed to perl_parse. so we
+     * have to workaround the logic to calculate PL_origalen in
+     * perl_parse, which is later used in set_mg.c:Perl_magic_set() to
+     * truncate the argv[0] setting.
+     */
+    if (PL_origalen < (strlen(MP_ap_server_argv0)+1)) {
+        PL_origalen = strlen(MP_ap_server_argv0) + 1;
+    };
+    sv_setpv(get_sv("0", TRUE), MP_ap_server_argv0);
+
     if (status) {
         perror("perl_parse");
         exit(1);
@@ -545,6 +558,11 @@

     /* perl 5.8.1+ */
     modperl_hash_seed_init(p);
+
+    /* it seems that Apache messes up with ap_server_argv0, so copy it
+     * away asap */
+    MP_ap_server_argv0 = apr_pstrmemdup(p, ap_server_argv0,
+                                        strlen(ap_server_argv0));

     return OK;
 }

__________________________________________________________________
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

--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to