perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject svn commit: r584380 - in /perl/modperl/trunk: Changes src/modules/perl/modperl_util.c t/modperl/pnotes2.t t/response/TestModperl/pnotes2.pm
Date Sat, 13 Oct 2007 06:48:16 GMT
Author: gozer
Date: Fri Oct 12 23:48:14 2007
New Revision: 584380

URL: http://svn.apache.org/viewvc?rev=584380&view=rev
Log:
Don't increase the refcnt of the pnotes HV* twice, we
will leak it.

Submitted-By: Torsten Foertsch <torsten.foertsch@gmx.net>
Message-Id: <200710111518.18560.torsten.foertsch@gmx.net>
Reviewed-By: gozer


Added:
    perl/modperl/trunk/t/modperl/pnotes2.t
    perl/modperl/trunk/t/response/TestModperl/pnotes2.pm
Modified:
    perl/modperl/trunk/Changes
    perl/modperl/trunk/src/modules/perl/modperl_util.c

Modified: perl/modperl/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/Changes?rev=584380&r1=584379&r2=584380&view=diff
==============================================================================
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Fri Oct 12 23:48:14 2007
@@ -12,6 +12,9 @@
 
 =item 2.0.4-dev
 
+Fix a bug that would prevent pnotes from being cleaned up proprely
+at the end of the request [Torsten Foertsch]
+
 On Win32, embed the manifest file, if present, in mod_perl.so,
 so as to work with VC 8 [Steve Hay, Randy Kobes]
 

Modified: perl/modperl/trunk/src/modules/perl/modperl_util.c
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/src/modules/perl/modperl_util.c?rev=584380&r1=584379&r2=584380&view=diff
==============================================================================
--- perl/modperl/trunk/src/modules/perl/modperl_util.c (original)
+++ perl/modperl/trunk/src/modules/perl/modperl_util.c Fri Oct 12 23:48:14 2007
@@ -895,11 +895,9 @@
         else if (hv_exists(*pnotes, k, len)) {
             retval = *hv_fetch(*pnotes, k, len, FALSE);
         }
-    }
-    else {
-        retval = newRV_inc((SV *)*pnotes);
-    }
 
-    return retval ? SvREFCNT_inc(retval) : &PL_sv_undef;
+        return retval ? SvREFCNT_inc(retval) : &PL_sv_undef;
+    }
+    return newRV_inc((SV *)*pnotes);
 }
  

Added: perl/modperl/trunk/t/modperl/pnotes2.t
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/modperl/pnotes2.t?rev=584380&view=auto
==============================================================================
--- perl/modperl/trunk/t/modperl/pnotes2.t (added)
+++ perl/modperl/trunk/t/modperl/pnotes2.t Fri Oct 12 23:48:14 2007
@@ -0,0 +1,32 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::TestRequest qw(GET_BODY);
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestUtil qw/t_start_error_log_watch t_finish_error_log_watch/;
+
+my $module = 'TestModperl::pnotes2';
+my $url    = Apache::TestRequest::module2url($module);
+my ($u, $ok);
+
+t_debug("connecting to $url");
+
+plan tests => 12, need_lwp;
+
+Apache::TestRequest::user_agent(reset => 1, keep_alive => 0);
+
+for my $i (1..12) {
+    t_client_log_warn_is_expected();
+    t_start_error_log_watch;
+    $u="$url?$i"; $ok=GET_BODY $u;
+    select undef, undef, undef, 0.2;  # give it time to write the logfile
+    ok t_cmp scalar(grep {
+	/pnotes are destroyed after cleanup passed/;
+    } t_finish_error_log_watch), 1, $u;
+}
+
+# Local Variables: #
+# mode: cperl #
+# cperl-indent-level: 4 #
+# End: #

Added: perl/modperl/trunk/t/response/TestModperl/pnotes2.pm
URL: http://svn.apache.org/viewvc/perl/modperl/trunk/t/response/TestModperl/pnotes2.pm?rev=584380&view=auto
==============================================================================
--- perl/modperl/trunk/t/response/TestModperl/pnotes2.pm (added)
+++ perl/modperl/trunk/t/response/TestModperl/pnotes2.pm Fri Oct 12 23:48:14 2007
@@ -0,0 +1,89 @@
+package TestModperl::pnotes2;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache2::Log ();
+use Apache2::RequestUtil ();
+use Apache2::ConnectionUtil ();
+
+use Apache2::Const -compile => 'OK';
+
+{
+    package TestModerl::pnotes2::x;
+    use strict;
+    use warnings FATAL => 'all';
+
+    sub new {shift;bless [@_];}
+    sub DESTROY {my $f=shift @{$_[0]}; $f->(@{$_[0]});}
+}
+
+sub line {
+    our $cleanup;
+
+    Apache2::ServerRec::warn "pnotes are destroyed after cleanup ".$cleanup;
+}
+
+sub cleanup {
+    our $cleanup;
+    $cleanup='passed';
+
+    return Apache2::Const::OK;
+}
+
+sub handler {
+    my $r = shift;
+
+    our $cleanup;
+    $cleanup='';
+
+    $r->push_handlers( PerlCleanupHandler=>__PACKAGE__.'::cleanup' );
+
+    if(!defined $r->args) {
+    } elsif($r->args == 1) {
+	$r->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+    } elsif($r->args == 2) {
+	$r->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+    } elsif($r->args == 3) {
+	$r->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+	$r->pnotes(x2 => 2);
+    } elsif($r->args == 4) {
+	$r->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+	$r->pnotes->{x2} = 2;
+    } elsif($r->args == 5) {
+	$r->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+	$r->pnotes->{x2} = 2;
+    } elsif($r->args == 6) {
+	$r->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+	$r->pnotes(x2 => 2);
+    } elsif($r->args == 7) {
+	$r->connection->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+    } elsif($r->args == 8) {
+	$r->connection->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+    } elsif($r->args == 9) {
+	$r->connection->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+	$r->connection->pnotes(x2 => 2);
+    } elsif($r->args == 10) {
+	$r->connection->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+	$r->connection->pnotes->{x2} = 2;
+    } elsif($r->args == 11) {
+	$r->connection->pnotes(x1 => TestModerl::pnotes2::x->new(\&line));
+	$r->connection->pnotes->{x2} = 2;
+    } elsif($r->args == 12) {
+	$r->connection->pnotes->{x1} = TestModerl::pnotes2::x->new(\&line);
+	$r->connection->pnotes(x2 => 2);
+    }
+
+    $r->content_type('text/plain');
+    $r->print("OK");
+
+    Apache2::Const::OK;
+}
+
+1;
+__END__
+
+# Local Variables: #
+# mode: cperl #
+# cperl-indent-level: 4 #
+# End: #



Mime
View raw message