perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [Patch] MP_GTOP=1
Date Mon, 19 May 2003 23:09:30 GMT
Philippe M. Chiasson wrote:
[...]
> Patches follows:
> 
> # $Id: gtop.patch,v 1.2 2003/05/19 13:43:06 gozer Exp $
> 
> Recently tried building with MP_GTOP=1 and noticed that things don't quite
> work anymore. As per gcc documentation __func__ and __FUNCTION__ should not
> be used in string concatenation. Also in modperl_imterp, encountered some
> scfg without a valid gtop structure, so create it if not already there
> 
> 
> Index: src/modules/perl/mod_perl.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
> retrieving revision 1.170
> diff -u -I$Id -r1.170 mod_perl.c
> --- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
> +++ src/modules/perl/mod_perl.c	19 May 2003 09:56:45 -0000
> @@ -147,7 +147,9 @@
>  
>  #ifdef MP_USE_GTOP
>      MP_TRACE_m_do(
> -        scfg->gtop = modperl_gtop_new(p);
> +        if (!scfg->gtop) {
> +            scfg->gtop = modperl_gtop_new(p);
> +        }
>          modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
>      );
>  #endif
> Index: src/modules/perl/modperl_interp.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v
> retrieving revision 1.58
> diff -u -I$Id -r1.58 modperl_interp.c
> --- src/modules/perl/modperl_interp.c	6 Apr 2003 23:49:46 -0000	1.58
> +++ src/modules/perl/modperl_interp.c	19 May 2003 09:56:45 -0000
> @@ -51,6 +51,9 @@
>  #ifdef MP_USE_GTOP
>          MP_dSCFG(mip->server);
>          MP_TRACE_m_do(
> +            if (!scfg->gtop) {
> +                scfg->gtop = modperl_gtop_new(scfg->server->process->pool);
> +            }
>              modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_clone");
>          );
>  #endif

I think that this patch (untested) is moving the init where it belongs to, 
rather than adding test-n-test code everywhere where it could segfault:

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.170
diff -u -r1.170 mod_perl.c
--- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
+++ src/modules/perl/mod_perl.c	19 May 2003 23:03:27 -0000
@@ -147,7 +147,6 @@

  #ifdef MP_USE_GTOP
      MP_TRACE_m_do(
-        scfg->gtop = modperl_gtop_new(p);
          modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
      );
  #endif
Index: src/modules/perl/modperl_config.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v
retrieving revision 1.62
diff -u -r1.62 modperl_config.c
--- src/modules/perl/modperl_config.c	3 Feb 2003 06:40:33 -0000	1.62
+++ src/modules/perl/modperl_config.c	19 May 2003 23:03:27 -0000
@@ -116,6 +116,10 @@

      MP_TRACE_d(MP_FUNC, "0x%lx\n", (unsigned long)scfg);

+#ifdef MP_USE_GTOP
+    scfg->gtop = modperl_gtop_new(p);
+#endif
+
      return scfg;
  }


> This patches fixes the concatenation problem with MP_FUNC (aka __func__ )
> 
> Index: src/modules/perl/mod_perl.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
> retrieving revision 1.170
> diff -u -I$Id -r1.170 mod_perl.c
> --- src/modules/perl/mod_perl.c	2 May 2003 01:35:03 -0000	1.170
> +++ src/modules/perl/mod_perl.c	19 May 2003 13:29:48 -0000
> @@ -150,7 +150,7 @@
>          if (!scfg->gtop) {
>              scfg->gtop = modperl_gtop_new(p);
>          }
> +        modperl_gtop_do_proc_mem_before(MP_FUNC, "perl_parse");
> -        modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_parse");
>      );
>  #endif
> 
> @@ -205,7 +205,7 @@
> 
>  #ifdef MP_USE_GTOP
>      MP_TRACE_m_do(
> +        modperl_gtop_do_proc_mem_after(MP_FUNC, "perl_parse");
> -        modperl_gtop_do_proc_mem_after(MP_FUNC ": perl_parse");
>      );
>  #endif
> 
>  
> Index: src/modules/perl/modperl_gtop.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_gtop.c,v
> retrieving revision 1.7
> diff -u -I$Id -r1.7 modperl_gtop.c
> --- src/modules/perl/modperl_gtop.c	15 Mar 2001 01:55:44 -0000	1.7
> +++ src/modules/perl/modperl_gtop.c	19 May 2003 13:29:48 -0000
> @@ -95,12 +95,12 @@
>  }
>  
>  void modperl_gtop_report_proc_mem(modperl_gtop_t *gtop, 
> -                                  char *when, char *msg)
> +                                  char *when, const char *func, char *msg)
>  {
>  #define ss_item(item) gtop->proc_mem_ss.item
>  
> -    fprintf(stderr, "%s %s: " ss_fmt "\n",
> -            msg, when,
> +    fprintf(stderr, "%s : %s %s: " ss_fmt "\n",
> +            func, msg, when,
>              ss_item(size),
>              ss_item(vsize),
>              ss_item(resident),
> @@ -110,22 +110,22 @@
>  #undef ss_item

While you are changing it, how about making msg an optional NULL? I suppose in 
some cases just passing func is good enough.

fprintf(stderr, "%s : %s %s: " ss_fmt "\n",
             func, (msg ? msg : ""), when,
             ...

Hey, does anybody know why C doesn't have msg||""? ;)



__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message