perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject Re: [Patch] MP_GTOP=1
Date Tue, 20 May 2003 04:53:56 GMT

On Tue, 2003-05-20 at 07:09, Stas Bekman wrote:
[...]
> 
> 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:

Yes stas, I thought about it but prefered to be lazy and leave the gtop
creation where it was. It does belong in the server config creation.

# $Id: gtop.patch,v 1.4 2003/05/20 04:52:37 gozer Exp $

First, better off create scfg->gtop at server config creation

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 -I$Id -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	20 May 2003 04:37:22 -0000
@@ -112,6 +112,10 @@
     scfg->PassEnv = apr_table_make(p, 2);
     scfg->SetEnv = apr_table_make(p, 2);
     
+#ifdef MP_USE_GTOP
+    scfg->gtop = modperl_gtop_new(p);
+#endif    
+    
     modperl_config_srv_argv_push((char *)ap_server_argv0);
 
     MP_TRACE_d(MP_FUNC, "0x%lx\n", (unsigned long)scfg);


Second, adjust for __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	20 May 2003 04:50:17 -0000
@@ -147,8 +147,7 @@
 
 #ifdef MP_USE_GTOP
     MP_TRACE_m_do(
-        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
 
@@ -203,7 +202,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	20 May 2003 04:50:17 -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 ? msg : ""), when,
             ss_item(size),
             ss_item(vsize),
             ss_item(resident),
@@ -110,22 +110,22 @@
 #undef ss_item
 }
 
-void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_DIFF);
-    modperl_gtop_report_proc_mem(gtop, "diff", msg);
+    modperl_gtop_report_proc_mem(gtop, "diff", func, msg);
 }
 
-void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_BEFORE);
-    modperl_gtop_report_proc_mem(gtop, "before", msg);
+    modperl_gtop_report_proc_mem(gtop, "before", func, msg);
 }
 
-void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, char *msg)
+void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, const char *func, char *msg)
 {
     modperl_gtop_proc_mem_size_string(gtop, SS_TYPE_AFTER);
-    modperl_gtop_report_proc_mem(gtop, "after", msg);
+    modperl_gtop_report_proc_mem(gtop, "after", func, msg);
 }
 
 #endif /* MP_USE_GTOP */
Index: src/modules/perl/modperl_gtop.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_gtop.h,v
retrieving revision 1.3
diff -u -I$Id -r1.3 modperl_gtop.h
--- src/modules/perl/modperl_gtop.h	15 Mar 2001 01:55:44 -0000	1.3
+++ src/modules/perl/modperl_gtop.h	20 May 2003 04:50:17 -0000
@@ -36,19 +36,19 @@
 void modperl_gtop_get_proc_mem_before(modperl_gtop_t *gtop);
 void modperl_gtop_get_proc_mem_after(modperl_gtop_t *gtop);
 void modperl_gtop_report_proc_mem(modperl_gtop_t *gtop, 
-                                  char *when, char *msg);
-void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, char *msg);
-void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, char *msg);
-void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, char *msg);
+                                  char *when, const char *func, char *msg);
+void modperl_gtop_report_proc_mem_diff(modperl_gtop_t *gtop, const char* func, char *msg);
+void modperl_gtop_report_proc_mem_before(modperl_gtop_t *gtop, const char* func, char *msg);
+void modperl_gtop_report_proc_mem_after(modperl_gtop_t *gtop, const char* func, char *msg);
 
-#define modperl_gtop_do_proc_mem_before(msg) \
+#define modperl_gtop_do_proc_mem_before(func, msg) \
         modperl_gtop_get_proc_mem_before(scfg->gtop); \
-        modperl_gtop_report_proc_mem_before(scfg->gtop, msg)
+        modperl_gtop_report_proc_mem_before(scfg->gtop, func, msg)
 
-#define modperl_gtop_do_proc_mem_after(msg) \
+#define modperl_gtop_do_proc_mem_after(func, msg) \
         modperl_gtop_get_proc_mem_after(scfg->gtop); \
-        modperl_gtop_report_proc_mem_after(scfg->gtop, msg); \
-        modperl_gtop_report_proc_mem_diff(scfg->gtop, msg)
+        modperl_gtop_report_proc_mem_after(scfg->gtop, func, msg); \
+        modperl_gtop_report_proc_mem_diff(scfg->gtop, func, msg)
 
 #endif /* MP_USE_GTOP */
 
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	20 May 2003 04:50:17 -0000
@@ -51,7 +51,7 @@
 #ifdef MP_USE_GTOP
         MP_dSCFG(mip->server);
         MP_TRACE_m_do(
-            modperl_gtop_do_proc_mem_before(MP_FUNC ": perl_clone");
+            modperl_gtop_do_proc_mem_before(MP_FUNC, "perl_clone");
         );
 #endif
 
@@ -99,7 +99,7 @@
 
 #ifdef MP_USE_GTOP
         MP_TRACE_m_do(
-            modperl_gtop_do_proc_mem_after(MP_FUNC ": perl_clone");
+            modperl_gtop_do_proc_mem_after(MP_FUNC, "perl_clone");
         );
 #endif
     }



> 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||""? ;)
> 

Because there is no spoon !;-p

> 
> __________________________________________________________________
> 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
-- 
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Mime
View raw message