perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject svn commit: r291193 - in /perl/modperl/trunk: Changes src/modules/perl/mod_perl.c src/modules/perl/modperl_config.c src/modules/perl/modperl_config.h src/modules/perl/modperl_module.c t/response/TestDirective/perldo.pm
Date Fri, 23 Sep 2005 19:30:56 GMT
Author: gozer
Date: Fri Sep 23 12:30:51 2005
New Revision: 291193

URL: http://svn.apache.org/viewcvs?rev=291193&view=rev
Log:
$0 Fixes :
- Setting $0 works on Linux again
- HP-UX and *BSDes show the correct process name instead of '-e'         

Bug-Report: http://thread.gmane.org/gmane.comp.apache.mod-perl/20847


Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/src/modules/perl/mod_perl.c
    perl/modperl/trunk/src/modules/perl/modperl_config.c
    perl/modperl/trunk/src/modules/perl/modperl_config.h
    perl/modperl/trunk/src/modules/perl/modperl_module.c
    perl/modperl/trunk/t/response/TestDirective/perldo.pm

Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Fri Sep 23 12:30:51 2005
@@ -12,6 +12,10 @@
 
 =item 2.0.2-dev
 
+$0 Fixes : [Gozer]
+- Setting $0 works on Linux again
+- HP-UX and *BSDes show the correct process name instead of '-e'
+ 
 Fix a cirtical but trivial bug that would cause MP_MAINTAINER=1
 or MP_TRACE=1 builds to fail if not building against a threaded APR.
 Functions such as apr_os_thread_current() would not be linked in,

Modified: perl/modperl/trunk/src/modules/perl/mod_perl.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/mod_perl.c?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/mod_perl.c (original)
+++ perl/modperl/trunk/src/modules/perl/mod_perl.c Fri Sep 23 12:30:51 2005
@@ -271,6 +271,13 @@
     PL_reentrant_buffer->_crypt_struct.current_saltbits = 0;
 #endif
 
+    /* We need to reset $0 to argv[0] (httpd) since perl_parse() will
+     * have set it to '-e'. Being magic-aware ensures that some
+     * OS-specific magic will happen (i.e. setproctitle() on *BSDs)
+     */
+    PL_origalen = strlen(argv[0]) + 1;
+    sv_setpv_mg(get_sv("0",0), argv[0]);
+
     perl_run(perl);
 
 #ifdef USE_ITHREADS

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_config.c?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.c Fri Sep 23 12:30:51 2005
@@ -147,7 +147,7 @@
     return rcfg;
 }
 
-modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p)
+modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p, server_rec *s)
 {
     modperl_config_srv_t *scfg = (modperl_config_srv_t *)
         apr_pcalloc(p, sizeof(*scfg));
@@ -173,18 +173,9 @@
     scfg->gtop = modperl_gtop_new(p);
 #endif        
 
-    /* must copy ap_server_argv0, because otherwise any read/write of
-     * $0 corrupts process' argv[0] (visible with 'ps -ef' on most
-     * unices). This is due to the logic of calculating PL_origalen in
-     * perl_parse, which is later used in set_mg.c:Perl_magic_set() to
-     * truncate the argv[0] setting. remember that argv[0] passed to
-     * perl_parse() != process's real argv[0].
-     *
-     * as a copying side-effect, changing $0 now doesn't affect the
-     * way the process is seen from the outside.
-     */
-    modperl_config_srv_argv_push(apr_pstrmemdup(p, ap_server_argv0,
-                                                strlen(ap_server_argv0)));
+    /* make sure httpd's argv[0] is the first argument so $0 is
+     * correctly connected to the real thing */
+    modperl_config_srv_argv_push(s->process->argv[0]);
 
     MP_TRACE_d(MP_FUNC, "new scfg: 0x%lx\n", (unsigned long)scfg);
 
@@ -233,7 +224,7 @@
 
 void *modperl_config_srv_create(apr_pool_t *p, server_rec *s)
 {
-    modperl_config_srv_t *scfg = modperl_config_srv_new(p);
+    modperl_config_srv_t *scfg = modperl_config_srv_new(p, s);
 
     if (!s->is_virtual) {
 
@@ -282,7 +273,7 @@
     modperl_config_srv_t
         *base = (modperl_config_srv_t *)basev,
         *add  = (modperl_config_srv_t *)addv,
-        *mrg  = modperl_config_srv_new(p);
+        *mrg  = modperl_config_srv_new(p, add->server);
 
     MP_TRACE_d(MP_FUNC, "basev==0x%lx, addv==0x%lx, mrg==0x%lx\n", 
                (unsigned long)basev, (unsigned long)addv,

Modified: perl/modperl/trunk/src/modules/perl/modperl_config.h
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_config.h?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_config.h (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_config.h Fri Sep 23 12:30:51 2005
@@ -20,7 +20,7 @@
 
 void *modperl_config_dir_merge(apr_pool_t *p, void *basev, void *addv);
 
-modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p);
+modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p, server_rec *s);
 
 modperl_config_dir_t *modperl_config_dir_new(apr_pool_t *p);
 

Modified: perl/modperl/trunk/src/modules/perl/modperl_module.c
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/src/modules/perl/modperl_module.c?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_module.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_module.c Fri Sep 23 12:30:51 2005
@@ -387,7 +387,7 @@
          * needed by the Perl callback.
          */
         if (!scfg) {
-            scfg = modperl_config_srv_new(p);
+            scfg = modperl_config_srv_new(p, s);
             modperl_set_module_config(s->module_config, scfg);
             scfg->server = s;
         }

Modified: perl/modperl/trunk/t/response/TestDirective/perldo.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/t/response/TestDirective/perldo.pm?rev=291193&r1=291192&r2=291193&view=diff
==============================================================================
--- perl/modperl/trunk/t/response/TestDirective/perldo.pm (original)
+++ perl/modperl/trunk/t/response/TestDirective/perldo.pm Fri Sep 23 12:30:51 2005
@@ -11,7 +11,7 @@
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 15;
+    plan $r, tests => 16;
 
     ok t_cmp('yes', $TestDirective::perl::worked);
 
@@ -39,7 +39,8 @@
     # 3 would mean we are still counting lines from the context of the eval
     ok $TestDirective::perl::line > 3;
 
-    ok t_cmp($0, "-e", '$0');
+    ok !t_cmp($0, '-e', '$0');
+    ok t_cmp($0, qr/httpd/, '$0');
 
     ok t_cmp($TestDirective::perl::Included, 1, "Include");
 



Mime
View raw message