perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fred Moyer" <f...@taperfriendlymusic.org>
Subject Re: [Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit]
Date Sat, 16 Feb 2008 22:07:53 GMT
> Sat Feb 16 11:11:48 2008: Request 33303 was acted upon.
> Transaction: Ticket created by jgoodridge@alum.dartmouth.org
> PROBLEM:
> If I turn off USE_SMAPS (i.e. set Apache::SizeLimit::USE_SMAPS=0), I get
> an
> error, specifically:

I just tested this out on my Centos 5.0 platform and it looks like
Apache::SizeLimit::USE_SMAPS is undefined for t/response/basic.pm.  The
test passed with and without the patch shown below.

I double checked it by explicitly setting $Apache::SizeLimit::USE_SMAPS=0
in t/response/basic.pm, same test results, and tested with
$Apache::SizeLimit::USE_SMAPS=1, same result.

However, if I set $Apache::SizeLimit::Core::USE_SMAPS=0 in basic.pm, I can
reproduce this bug.  $USE_SMAPS, $VERSION, and $REQUEST_COUNT were not
being exported by Apache::SizeLimit::Core.

> Can't call method "_linux_size_check" on an undefined value at

Here is my suggested set of patches to fix these issues, with an
additional test that demonstrated the failure, and success with the code
updates.

Index: t/response/TestApache/basic.pm
===================================================================
--- t/response/TestApache/basic.pm      (revision 628377)
+++ t/response/TestApache/basic.pm      (working copy)
@@ -15,7 +15,7 @@
 sub handler {
     my $r = shift;

-    plan $r, tests => 12;
+    plan $r, tests => 13;

     ok( ! Apache::SizeLimit->_limits_are_exceeded(),
         'check that _limits_are_exceeded() returns false without any
limits set' );
@@ -24,6 +24,16 @@
         my ( $size, $shared ) = Apache::SizeLimit->_check_size();
         cmp_ok( $size, '>', 0, 'proc size is reported > 0' );

+        {
+            # test with USE_SMAPS=0
+            my $smaps = $Apache::SizeLimit::USE_SMAPS;
+            $Apache::SizeLimit::USE_SMAPS = 0;
+            my ( $size, $shared ) = Apache::SizeLimit->_check_size();
+            cmp_ok( $size, '>', 0, 'proc size is reported > 0' );
+            $Apache::SizeLimit::USE_SMAPS = $smaps;
+        }
+
+
     SKIP:
         {
             skip 'I have no idea what getppid() on Win32 might return', 1
Index: lib/Apache/SizeLimit.pm
===================================================================
--- lib/Apache/SizeLimit.pm     (revision 628377)
+++ lib/Apache/SizeLimit.pm     (working copy)
@@ -32,6 +32,9 @@
                              $MIN_SHARE_SIZE
                              $CHECK_EVERY_N_REQUESTS
                              $START_TIME
+                             $USE_SMAPS
+                             $VERSION
+                             $REQUEST_COUNT
                             );
 use vars qw(@ISA);
 @ISA = qw(Apache::SizeLimit::Core);
Index: lib/Apache/SizeLimit/Core.pm
===================================================================
--- lib/Apache/SizeLimit/Core.pm        (revision 628377)
+++ lib/Apache/SizeLimit/Core.pm        (working copy)
@@ -38,6 +38,9 @@
 @ISA = qw(Exporter);

 @EXPORT_OK = qw(
+                $VERSION
+                $REQUEST_COUNT
+                $USE_SMAPS
                 $MAX_PROCESS_SIZE
                 $MAX_UNSHARED_SIZE
                 $MIN_SHARE_SIZE
@@ -111,8 +114,10 @@
 }

 sub _check_size {
-    my ($size, $share) = _platform_check_size();
+    my $class = shift;

+    my ($size, $share) = $class->_platform_check_size();
+
     return ($size, $share, $size - $share);
 }



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


Mime
View raw message