perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0 Changes
Date Sat, 11 Oct 2003 08:01:00 GMT
stas        2003/10/11 01:01:00

  Modified:    src/modules/perl modperl_callback.c
               .        Changes
  Log:
  callbacks returning values which aren't integers or strings (which are
  to be coerced into integers) are now interpreted as errors.
  Submitted by:	Geoffrey Young
  
  Revision  Changes    Path
  1.63      +21 -9     modperl-2.0/src/modules/perl/modperl_callback.c
  
  Index: modperl_callback.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_callback.c,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -u -r1.62 -r1.63
  --- modperl_callback.c	9 Oct 2003 19:41:41 -0000	1.62
  +++ modperl_callback.c	11 Oct 2003 08:01:00 -0000	1.63
  @@ -4,7 +4,6 @@
                        request_rec *r, server_rec *s, AV *args)
   {
       CV *cv=Nullcv;
  -    SV *status_sv;
       I32 flags = G_EVAL|G_SCALAR;
       dSP;
       int count, status = OK;
  @@ -76,20 +75,33 @@
               status = OK;
           }
           else {
  -            status_sv = POPs;
  +            SV *status_sv = POPs;
   
  -            if (status_sv == &PL_sv_undef) {
  -                /* ModPerl::Util::exit(), die(), or other croaks
  -                 * Perl_croak sets count to 1 but the stack to undef with G_EVAL|G_SCALAR
  -                 * if it was an error, it will be caught with ERRSV below */
  +            if (SvIOK(status_sv)) {
  +                /* normal IV return (e.g., Apache::OK) */
  +                status = SvIVX(status_sv);
  +            }
  +            else if (status_sv == &PL_sv_undef) {
  +                /* ModPerl::Util::exit() and Perl_croak internally
  +                 * arrange to return PL_sv_undef with G_EVAL|G_SCALAR */
                   status = OK; 
               }
  +            else if (SvPOK(status_sv)) {
  +                /* PV return that ought to be treated as IV ("0") */
  +                status = SvIVx(status_sv);
  +                MP_TRACE_h(MP_FUNC,
  +                           "coercing handler %s's return value '%s' into %d",
  +                           handler->name, SvPVX(status_sv), status);
  +            }
               else {
  -                /* get the integer return code (or a string coerced into an int) */
  -                status = SvIV(status_sv);
  +                /* any other return types are considered as errors */
  +                status = HTTP_INTERNAL_SERVER_ERROR;
  +                ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
  +                             "handler %s didn't return a valid return value!",
  +                             handler->name);
               }
   
  -            /* assume OK for non-http status codes and for 200 (HTTP_OK) */
  +            /* assume OK for non-HTTP status codes and for 200 (HTTP_OK) */
               if (((status > 0) && (status < 100)) ||
                   (status == 200) || (status > 600)) {
                   status = OK;
  
  
  
  1.234     +4 -3      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.233
  retrieving revision 1.234
  diff -u -u -r1.233 -r1.234
  --- Changes	9 Oct 2003 22:48:58 -0000	1.233
  +++ Changes	11 Oct 2003 08:01:00 -0000	1.234
  @@ -12,12 +12,13 @@
   
   =item 1.99_11-dev - 
   
  +callbacks returning values which aren't integers or strings (which are
  +to be coerced into integers) are now interpreted as errors. [Geoffrey
  +Young]
  +
   in the MP_MAINTAINER mode add the -Werror compilation flag when perl
   v5.6.2 or higher is used, so that we don't miss compilation
   warnings. [Stas]
  -
  -handlers returning status numbers as strings (e.g. "0") are working
  -again (as they did before 1.99_10). [Geoffrey Young]
   
   fix the Makefile.PL option parser to support overriding of certain
   build options, in addition to appending to them (.e.g. now MP_LIBNAME
  
  
  

Mime
View raw message