geoff       2003/12/01 09:14:17

  Modified:    xs/Apache/MPM Apache__MPM.h
               xs/maps  apache_functions.map modperl_functions.map
               xs/tables/current/Apache FunctionTable.pm
               xs/tables/current/ModPerl FunctionTable.pm
  Added:       t/response/TestAPI query.pm show.pm
  Removed:     t/response/TestAPI mpm_query.pm show_mpm.pm
  Log:
  change Apache::MPM::show_mpm() to constant subroutine Apache::MPM->show
  change Apache::MPM::mpm_query() to class method Apache::MPM->query()
  adjust test names to match
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/response/TestAPI/query.pm
  
  Index: query.pm
  ===================================================================
  package TestAPI::query;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  use Apache::TestTrace;
  
  use Apache::MPM ();
  
  use Apache::Const -compile => qw(OK :mpmq);
  
  sub handler {
  
      my $r = shift;
  
      plan $r, tests => 3;
  
      # ok, this isn't particularly pretty, but I can't think
      # of a better way to do it
      # all of these attributes I pulled right from the C sources
      # so if, say, leader all of a sudden changes its properties,
      # these tests will fail
  
      my $mpm = lc Apache::MPM->show;
  
      if ($mpm eq 'prefork') {
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_THREADED);
  
              ok t_cmp(Apache::MPMQ_NOT_SUPPORTED,
                       $query,
                       "MPMQ_IS_THREADED ($mpm)");
          }
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_FORKED);
  
              ok t_cmp(Apache::MPMQ_DYNAMIC,
                       $query,
                       "MPMQ_IS_FORKED ($mpm)");
          }
  
      }
      elsif ($mpm eq 'worker') {
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_THREADED);
  
              ok t_cmp(Apache::MPMQ_STATIC,
                       $query,
                       "MPMQ_IS_THREADED ($mpm)");
          }
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_FORKED);
  
              ok t_cmp(Apache::MPMQ_DYNAMIC,
                       $query,
                       "MPMQ_IS_FORKED ($mpm)");
          }
      }
      elsif ($mpm eq 'leader') {
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_THREADED);
  
              ok t_cmp(Apache::MPMQ_STATIC,
                       $query,
                       "MPMQ_IS_THREADED ($mpm)");
          }
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_FORKED);
  
              ok t_cmp(Apache::MPMQ_DYNAMIC,
                       $query,
                       "MPMQ_IS_FORKED ($mpm)");
          }
      }
      elsif ($mpm eq 'winnt') {
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_THREADED);
  
              ok t_cmp(Apache::MPMQ_STATIC,
                       $query,
                       "MPMQ_IS_THREADED ($mpm)");
          }
  
          {
              my $query = Apache::MPM->query(Apache::MPMQ_IS_FORKED);
  
              ok t_cmp(Apache::MPMQ_NOT_SUPPORTED,
                       $query,
                       "MPMQ_IS_FORKED ($mpm)");
          }
      }
      else {
          skip "skipping MPMQ_IS_THREADED test for $mpm MPM", 0;
          skip "skipping MPMQ_IS_FORKED test for $mpm MPM", 0;
      }
  
      # make sure that an undefined MPMQ constant yields undef
      {
          my $query = Apache::MPM->query(72);
  
          ok t_cmp(undef,
                   $query,
                   "unknown MPMQ value returns undef");
      }
  
      Apache::OK;
  }
  
  1;
  
  
  
  1.1                  modperl-2.0/t/response/TestAPI/show.pm
  
  Index: show.pm
  ===================================================================
  package TestAPI::show;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  
  use Apache::MPM ();
  use Apache::Const -compile => 'OK';
  
  sub handler {
      my $r = shift;
  
      plan $r, tests => 1;
  
      my $mpm = Apache::Test::config->{server}->{mpm};
  
      warn "**** trying now***";
  
      ok t_cmp(qr!$mpm!i,
               Apache::MPM->show(),
               'Apache::MPM->show()');
  
      Apache::OK;
  }
  
  1;
  
  
  
  1.2       +17 -9     modperl-2.0/xs/Apache/MPM/Apache__MPM.h
  
  Index: Apache__MPM.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/Apache/MPM/Apache__MPM.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Apache__MPM.h     25 Nov 2003 18:56:34 -0000      1.1
  +++ Apache__MPM.h     1 Dec 2003 17:14:16 -0000       1.2
  @@ -1,17 +1,25 @@
  -static MP_INLINE
  -int mpxs_Apache__MPM_mpm_query(int query)
  +static MP_INLINE SV *mpxs_Apache__MPM_query(pTHX_ SV *self, int query_code)
   {
       int mpm_query_info;
   
  -    apr_status_t retval = ap_mpm_query(query, &mpm_query_info);
  +    apr_status_t retval = ap_mpm_query(query_code, &mpm_query_info);
   
       if (retval == APR_SUCCESS) {
  -        return mpm_query_info;
  +        return newSViv(mpm_query_info);
       }
   
  -    /* XXX hmm... what to do here.  die?
  -     * APR_ENOTIMPL should be sufficiently large
  -     * that comparison tests fail... I think...
  -     */
  -    return (int) retval;
  +    return &PL_sv_undef;
  +}
  +
  +static void mpxs_Apache__MPM_BOOT(pTHX)
  +{
  +    /* implement Apache::MPM->show as a constant subroutine
  +     * since this information will never
  +     * change during an interpreter's lifetime */
  +
  +    MP_TRACE_g(MP_FUNC, "defined Apache::MPM->show() as %s\n",
  +               ap_show_mpm());
  +
  +    newCONSTSUB(PL_defstash, "Apache::MPM::show",
  +                newSVpv(ap_show_mpm(), 0));
   }
  
  
  
  1.66      +3 -3      modperl-2.0/xs/maps/apache_functions.map
  
  Index: apache_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- apache_functions.map      25 Nov 2003 18:56:34 -0000      1.65
  +++ apache_functions.map      1 Dec 2003 17:14:16 -0000       1.66
  @@ -488,8 +488,9 @@
   !MODULE=Apache::XML
    ap_xml_parse_input
   
  -MODULE=Apache::MPM
  - ap_mpm_query
  +MODULE=Apache::MPM   PACKAGE=Apache::MPM   BOOT=1
  +~ap_mpm_query
  +~ap_show_mpm
   >ap_mpm_run
   ?ap_os_create_privileged_process
   ?ap_wait_or_timeout
  @@ -511,5 +512,4 @@
   ?ap_mpm_set_max_requests
   ?ap_mpm_set_pidfile
   ?ap_mpm_set_scoreboard
  - ap_show_mpm
   ?ap_listen_pre_config
  
  
  
  1.61      +2 -2      modperl-2.0/xs/maps/modperl_functions.map
  
  Index: modperl_functions.map
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- modperl_functions.map     25 Nov 2003 18:56:34 -0000      1.60
  +++ modperl_functions.map     1 Dec 2003 17:14:16 -0000       1.61
  @@ -135,5 +135,5 @@
   MODULE=Apache::CmdParms
    mpxs_Apache__CmdParms_info
   
  -MODULE=Apache::MPM
  - mpxs_Apache__MPM_mpm_query
  +MODULE=Apache::MPM    PACKAGE=Apache::MPM   BOOT=1
  + mpxs_Apache__MPM_query
  
  
  
  1.48      +14 -0     modperl-2.0/xs/tables/current/Apache/FunctionTable.pm
  
  Index: FunctionTable.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/tables/current/Apache/FunctionTable.pm,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- FunctionTable.pm  29 Aug 2003 14:31:00 -0000      1.47
  +++ FunctionTable.pm  1 Dec 2003 17:14:16 -0000       1.48
  @@ -3104,6 +3104,20 @@
       ]
     },
     {
  +    'return_type' => 'apr_status_t',
  +    'name' => 'ap_mpm_query',
  +    'args' => [
  +      {
  +        'type' => 'int',
  +        'name' => 'query_code'
  +      },
  +      {
  +        'type' => 'int',
  +        'name' => 'result'
  +      }
  +    ]
  +  },
  +  {
       'return_type' => 'void',
       'name' => 'ap_mpm_rewrite_args',
       'args' => [
  
  
  
  1.132     +28 -3     modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm
  
  Index: FunctionTable.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- FunctionTable.pm  25 Nov 2003 18:56:34 -0000      1.131
  +++ FunctionTable.pm  1 Dec 2003 17:14:17 -0000       1.132
  @@ -6899,12 +6899,37 @@
       ]
     },
     {
  -    'return_type' => 'int',
  -    'name' => 'mpxs_Apache__MPM_mpm_query',
  +    'return_type' => 'SV *',
  +    'name' => 'mpxs_Apache__MPM_query',
  +    'attr' => [
  +      'static',
  +      '__inline__'
  +    ],
       'args' => [
         {
  +        'type' => 'PerlInterpreter *',
  +        'name' => 'my_perl'
  +      },
  +      {
  +        'type' => 'SV *',
  +        'name' => 'self'
  +      },
  +      {
           'type' => 'int',
  -        'name' => 'query'
  +        'name' => 'query_code'
  +      }
  +    ]
  +  },
  +  {
  +    'return_type' => 'void',
  +    'name' => 'mpxs_Apache__MPM_BOOT',
  +    'attr' => [
  +      'static'
  +    ],
  +    'args' => [
  +      {
  +        'type' => 'PerlInterpreter *',
  +        'name' => 'my_perl'
         }
       ]
     },
  
  
  

Reply via email to