MP_FUNC & MP_CHECK_WBUCKET_INIT

View: New views
2 Messages — Rating Filter:   Alert me  

MP_FUNC & MP_CHECK_WBUCKET_INIT

by Torsten Foertsch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

MP_FUNC is NULL unless MP_TRACE is set (modperl_common_log.h).

MP_CHECK_WBUCKET_INIT is defined as (modperl_util.h):

#define MP_CHECK_WBUCKET_INIT(func) \
    if (!rcfg->wbucket) { \
        Perl_croak(aTHX_ "%s: " func " can't be called "  \
                   "before the response phase", MP_FUNC); \
    }

It doesn't check for MP_TRACE and hence passes a NULL pointer to
Perl_croak(%s).

How about this fix?

Index: src/modules/perl/modperl_util.h
===================================================================
--- src/modules/perl/modperl_util.h     (revision 681109)
+++ src/modules/perl/modperl_util.h     (working copy)
@@ -20,11 +20,19 @@
 #include "modperl_common_util.h"

 /* check whether the response phase has been initialized already */
-#define MP_CHECK_WBUCKET_INIT(func) \
-    if (!rcfg->wbucket) { \
-        Perl_croak(aTHX_ "%s: " func " can't be called "  \
-                   "before the response phase", MP_FUNC); \
+#ifdef MP_TRACE
+#   define MP_CHECK_WBUCKET_INIT(func) \
+        if (!rcfg->wbucket) { \
+            Perl_croak(aTHX_ "%s: " func " can't be called " \
+                       "before the response phase", MP_FUNC); \
     }
+#else
+#   define MP_CHECK_WBUCKET_INIT(func) \
+        if (!rcfg->wbucket) { \
+            Perl_croak(aTHX_ func " can't be called " \
+                       "before the response phase"); \
+    }
+#endif

 /* turn off cgi header parsing. in case we are already inside
  *     modperl_callback_per_dir(MP_RESPONSE_HANDLER, r, MP_HOOK_RUN_FIRST);


--
Need professional mod_perl support?
Just hire me: torsten.foertsch@...

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


Re: MP_FUNC & MP_CHECK_WBUCKET_INIT

by Philip M. Gollucci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Torsten Foertsch wrote:

> Hi,
>
> MP_FUNC is NULL unless MP_TRACE is set (modperl_common_log.h).
>
> MP_CHECK_WBUCKET_INIT is defined as (modperl_util.h):
>
> #define MP_CHECK_WBUCKET_INIT(func) \
>     if (!rcfg->wbucket) { \
>         Perl_croak(aTHX_ "%s: " func " can't be called "  \
>                    "before the response phase", MP_FUNC); \
>     }
>
> It doesn't check for MP_TRACE and hence passes a NULL pointer to
> Perl_croak(%s).
Makes sense to me.  I compile with MP_TRACE=1 all the time and even have
flags 'A'.  How have I not hit this yet  ?

P.S.
I didn't actually look at the modperl_common_log.h



--
------------------------------------------------------------------------
Philip M. Gollucci (philip@...)
o:703.549.2050x206
Senior System Admin - Riderway, Inc.
http://riderway.com / http://ridecharge.com
1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70  3F8C 75B8 8FFB DB9B 8C1C

Work like you don't need the money,
love like you'll never get hurt,
and dance like nobody's watching.


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

LightInTheBox - Buy quality products at wholesale price!