Author: pgollucci
Date: Tue Aug 22 22:51:39 2006
New Revision: 433914

URL: http://svn.apache.org/viewvc?rev=433914&view=rev
Log:
o pull _exit_if_too_big into target specific
o apr_child_terminate() works on Win32 in 2.x series.


Modified:
    perl/Apache-SizeLimit/trunk/lib/Apache/BaseSizeLimit.pm
    perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit.pm
    perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit2.pm

Modified: perl/Apache-SizeLimit/trunk/lib/Apache/BaseSizeLimit.pm
URL: 
http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/lib/Apache/BaseSizeLimit.pm?rev=433914&r1=433913&r2=433914&view=diff
==============================================================================
--- perl/Apache-SizeLimit/trunk/lib/Apache/BaseSizeLimit.pm (original)
+++ perl/Apache-SizeLimit/trunk/lib/Apache/BaseSizeLimit.pm Tue Aug 22 22:51:39 
2006
@@ -64,45 +64,6 @@
     $CHECK_EVERY_N_REQUESTS = shift;
 }
 
-sub _exit_if_too_big {
-    my $class = shift;
-    my $r = shift;
-
-    return DECLINED
-        if ($CHECK_EVERY_N_REQUESTS
-             && ($REQUEST_COUNT++ % $CHECK_EVERY_N_REQUESTS));
-
-    $START_TIME ||= time;
-
-    if ($class->_limits_are_exceeded()) {
-        my ($size, $share, $unshared) = $class->_check_size();
-
-        if (IS_WIN32 || $class->_platform_getppid() > 1) {
-            # this is a child httpd
-            my $e   = time - $START_TIME;
-            my $msg = "httpd process too big, exiting at SIZE=$size KB";
-            $msg .= " SHARE=$share KB UNSHARED=$unshared" if ($share);
-            $msg .= " REQUESTS=$REQUEST_COUNT  LIFETIME=$e seconds";
-            $class->_error_log($msg);
-
-            if (IS_WIN32) {
-                # child_terminate() is disabled in win32 Apache
-                CORE::exit(-2);
-            }
-            else {
-                $r->child_terminate();
-            }
-        }
-        else {
-            # this is the main httpd, whose parent is init?
-            my $msg = "main process too big, SIZE=$size KB ";
-            $msg .= " SHARE=$share KB" if ($share);
-            $class->_error_log($msg);
-        }
-    }
-    return OK;
-}
-
 # REVIEW - Why doesn't this use $r->warn or some other
 # Apache/Apache::Log API?
 sub _error_log {

Modified: perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit.pm
URL: 
http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit.pm?rev=433914&r1=433913&r2=433914&view=diff
==============================================================================
--- perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit.pm (original)
+++ perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit.pm Tue Aug 22 22:51:39 2006
@@ -16,8 +16,11 @@
 package Apache::SizeLimit;
 
 use strict;
+use Config;
 
-use Apache::Constants qw(DECLINED OK);
+use Apache::Constants ();
+
+use constant IS_WIN32 => $Config{'osname'} eq 'MSWin32' ? 1 : 0;
 
 use vars qw($VERSION);
 
@@ -27,7 +30,7 @@
     my $class = shift;
     my $r = shift || Apache->request;
 
-    return DECLINED unless $r->is_main();
+    return Apache::Constants::DECLINED() unless $r->is_main();
 
     # we want to operate in a cleanup handler
     if ($r->current_callback eq 'PerlCleanupHandler') {
@@ -37,7 +40,7 @@
         $class->add_cleanup_handler($r);
     }
 
-    return DECLINED;
+    return Apache::Constants::DECLINED();
 }
 
 sub add_cleanup_handler {
@@ -54,6 +57,45 @@
     $r->push_handlers('PerlCleanupHandler',
                       sub { $class->_exit_if_too_big(shift) });
     $r->pnotes(size_limit_cleanup => 1);
+}
+
+sub _exit_if_too_big {
+    my $class = shift;
+    my $r = shift;
+
+    return Apache::Constants::DECLINED()
+        if ($CHECK_EVERY_N_REQUESTS
+             && ($REQUEST_COUNT++ % $CHECK_EVERY_N_REQUESTS));
+
+    $START_TIME ||= time;
+
+    if ($class->_limits_are_exceeded()) {
+        my ($size, $share, $unshared) = $class->_check_size();
+
+        if (IS_WIN32 || $class->_platform_getppid() > 1) {
+            # this is a child httpd
+            my $e   = time - $START_TIME;
+            my $msg = "httpd process too big, exiting at SIZE=$size KB";
+            $msg .= " SHARE=$share KB UNSHARED=$unshared" if ($share);
+            $msg .= " REQUESTS=$REQUEST_COUNT  LIFETIME=$e seconds";
+            $class->_error_log($msg);
+
+            if (IS_WIN32) {
+                # child_terminate() is disabled in win32 Apache
+                CORE::exit(-2);
+            }
+            else {
+                $r->child_terminate();
+            }
+        }
+        else {
+            # this is the main httpd, whose parent is init?
+            my $msg = "main process too big, SIZE=$size KB ";
+            $msg .= " SHARE=$share KB" if ($share);
+            $class->_error_log($msg);
+        }
+    }
+    return Apache::Constants::OK();
 }
 
 1;

Modified: perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit2.pm
URL: 
http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit2.pm?rev=433914&r1=433913&r2=433914&view=diff
==============================================================================
--- perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit2.pm (original)
+++ perl/Apache-SizeLimit/trunk/lib/Apache/SizeLimit2.pm Tue Aug 22 22:51:39 
2006
@@ -16,12 +16,15 @@
 package Apache2::SizeLimit;
 
 use strict;
+use Config;
 
 use Apache2::RequestUtil ();
 use Apache2::Const -compile => qw (DECLINED OK);
 
 use ModPerl::Util ();
 
+use constant IS_WIN32 => $Config{'osname'} eq 'MSWin32' ? 1 : 0;
+
 # 2.x requires 5.6.x+ so 'our' is okay
 our $VERSION = '0.91-dev';
 
@@ -59,6 +62,39 @@
                      );
 
     $r->pnotes(size_limit_cleanup => 1);
+}
+
+sub _exit_if_too_big {
+    my $class = shift;
+    my $r = shift;
+
+    return Apache2::Const::DECLINED
+        if ($CHECK_EVERY_N_REQUESTS
+             && ($REQUEST_COUNT++ % $CHECK_EVERY_N_REQUESTS));
+
+    $START_TIME ||= time;
+
+    if ($class->_limits_are_exceeded()) {
+        my ($size, $share, $unshared) = $class->_check_size();
+
+        if (IS_WIN32 || $class->_platform_getppid() > 1) {
+            # this is a child httpd
+            my $e   = time - $START_TIME;
+            my $msg = "httpd process too big, exiting at SIZE=$size KB";
+            $msg .= " SHARE=$share KB UNSHARED=$unshared" if ($share);
+            $msg .= " REQUESTS=$REQUEST_COUNT  LIFETIME=$e seconds";
+            $class->_error_log($msg);
+
+            $r->child_terminate();
+        }
+        else {
+            # this is the main httpd, whose parent is init?
+            my $msg = "main process too big, SIZE=$size KB ";
+            $msg .= " SHARE=$share KB" if ($share);
+            $class->_error_log($msg);
+        }
+    }
+    return Apache2::Const::OK;
 }
 
 1;


Reply via email to