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/src/modules/perl modperl_callback.c
Date Thu, 30 Sep 2004 03:30:29 GMT
stas        2004/09/29 20:30:29

  Modified:    .        Changes
               src/modules/perl modperl_callback.c
  Added:       t/hooks/TestHooks inlined_handlers.pm
               t/hooks  inlined_handlers.t
  Log:
  fix a bug in non-ithreaded-perl implementation where the cached
  compiled CODE refs of httpd.conf-inlined one-liner handlers like:
  PerlFixupHandler 'sub { use Apache::Const qw(DECLINED); DECLINED }'
  didn't have the reference count right.
  
  Revision  Changes    Path
  1.1                  modperl-2.0/t/hooks/TestHooks/inlined_handlers.pm
  
  Index: inlined_handlers.pm
  ===================================================================
  package TestHooks::inlined_handlers;
  
  # this test exercises httpd.conf inlined one-liner handlers, like:
  #   PerlFixupHandler 'sub { use Apache::Const qw(DECLINED); DECLINED }'
  # previously there was a bug in non-ithreaded-perl implementation
  # where the cached compiled CODE ref didn't have the reference count
  # right.
  #
  # this test needs to run via the same_interpr framework, since it must
  # test that the same perl interprter/process gets to run the same
  # inlined handler
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::RequestIO ();
  
  use Apache::Const -compile => 'OK';
  
  sub handler {
      my $r = shift;
  
      $r->print('ok');
  
      Apache::OK;
  }
  
  1;
  __DATA__
  <NoAutoConfig>
    <Location /TestHooks__inlined_handlers>
        SetHandler modperl
        PerlInitHandler     Apache::TestHandler::same_interp_fixup
        PerlFixupHandler    'sub { use Apache::Const qw(DECLINED); DECLINED }'
        PerlResponseHandler TestHooks::inlined_handlers
    </Location>
  </NoAutoConfig>
  
  
  
  1.1                  modperl-2.0/t/hooks/inlined_handlers.t
  
  Index: inlined_handlers.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  use Apache::TestRequest;
  
  plan tests => 2;
  
  my $location = "/TestHooks__inlined_handlers";
  
  t_debug "getting the same interp ID for $location";
  my $same_interp = Apache::TestRequest::same_interp_tie($location);
  
  my $skip = $same_interp ? 0 : 1;
  my $expected = "ok";
  for (1..2) {
      my $received = get_body($same_interp, \&GET, $location);
      $skip++ unless defined $received;
      skip_not_same_interp(
          $skip,
          $received,
          $expected,
          "anonymous handlers in httpd.conf test"
      );
  }
  
  # if we fail to find the same interpreter, return undef (this is not
  # an error)
  sub get_body {
      my $res = eval {
          Apache::TestRequest::same_interp_do(@_);
      };
      return undef if $@ =~ /unable to find interp/;
      return $res->content if $res;
      die $@ if $@;
  }
  
  # make the tests resistant to a failure of finding the same perl
  # interpreter, which happens randomly and not an error.
  # the first argument is used to decide whether to skip the sub-test,
  # the rest of the arguments are passed to 'ok t_cmp';
  sub skip_not_same_interp {
      my $skip_cond = shift;
      if ($skip_cond) {
          skip "Skip couldn't find the same interpreter", 0;
      }
      else {
          my($package, $filename, $line) = caller;
          # trick ok() into reporting the caller filename/line when a
          # sub-test fails in sok()
          return eval <<EOE;
  #line $line $filename
      ok &t_cmp;
  EOE
      }
  }
  
  
  
  1.504     +5 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.503
  retrieving revision 1.504
  diff -u -u -r1.503 -r1.504
  --- Changes	28 Sep 2004 18:14:30 -0000	1.503
  +++ Changes	30 Sep 2004 03:30:29 -0000	1.504
  @@ -12,6 +12,11 @@
   
   =item 1.99_17-dev
   
  +fix a bug in non-ithreaded-perl implementation where the cached
  +compiled CODE refs of httpd.conf-inlined one-liner handlers like:
  +PerlFixupHandler 'sub { use Apache::Const qw(DECLINED); DECLINED }'
  +didn't have the reference count right. [Stas]
  +
   per-server PerlSetEnv and PerlPassEnv values are properly added
   to %ENV when only a per-directory handler is configured.
   [Geoffrey Young]
  
  
  
  1.80      +1 -0      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.79
  retrieving revision 1.80
  diff -u -u -r1.79 -r1.80
  --- modperl_callback.c	29 Sep 2004 20:57:51 -0000	1.79
  +++ modperl_callback.c	30 Sep 2004 03:30:29 -0000	1.80
  @@ -79,6 +79,7 @@
           if (!handler->cv) {
               SV *sv = eval_pv(handler->name, TRUE); 
               handler->cv = (CV*)SvRV(sv); /* cache */
  +            SvREFCNT_inc(handler->cv);
           }
           cv = handler->cv;
   #endif
  
  
  

Mime
View raw message