Author: pgollucci Date: Tue Sep 6 19:04:55 2005 New Revision: 279210 URL: http://svn.apache.org/viewcvs?rev=279210&view=rev Log: enable smaps support on linux systems that support it.
Submitted By: Torsten Foertsch <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Modified: perl/modperl/trunk/Changes perl/modperl/trunk/lib/Apache2/SizeLimit.pm Modified: perl/modperl/trunk/Changes URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/Changes?rev=279210&r1=279209&r2=279210&view=diff ============================================================================== --- perl/modperl/trunk/Changes (original) +++ perl/modperl/trunk/Changes Tue Sep 6 19:04:55 2005 @@ -12,6 +12,11 @@ =item 2.0.2-dev +Add support for the newer Smaps (/proc/self/statm) on Linux +systems that support it (i.e. linux-2.6.13-rc4-mm1) +to accurately count the amount of shared memory. +[Torsten Foertsch <torsten.foertsch gmx.net>] + On cygwin some dlls might happen to be with identical base addresses and if you try to load both of them you'll get an error and you'll have to use the rebase utility to fix them. this fix should prevent Modified: perl/modperl/trunk/lib/Apache2/SizeLimit.pm URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/Apache2/SizeLimit.pm?rev=279210&r1=279209&r2=279210&view=diff ============================================================================== --- perl/modperl/trunk/lib/Apache2/SizeLimit.pm (original) +++ perl/modperl/trunk/lib/Apache2/SizeLimit.pm Tue Sep 6 19:04:55 2005 @@ -34,13 +34,14 @@ use Apache2::Const -compile => qw(OK DECLINED); -our $VERSION = '0.04'; +our $VERSION = '0.05'; our $CHECK_EVERY_N_REQUESTS = 1; our $REQUEST_COUNT = 1; our $MAX_PROCESS_SIZE = 0; our $MIN_SHARE_SIZE = 0; our $MAX_UNSHARED_SIZE = 0; +our $USE_SMAPS = 1; our ($HOW_BIG_IS_IT, $START_TIME); @@ -55,9 +56,12 @@ $HOW_BIG_IS_IT = \&solaris_2_6_size_check; } elsif (LINUX) { - - $HOW_BIG_IS_IT = \&linux_size_check; - + if ( eval { require Linux::Smaps } and Linux::Smaps->new($$) ) { + $HOW_BIG_IS_IT = \&linux_smaps_size_check_first_time; + } else { + $USE_SMAPS = 0; + $HOW_BIG_IS_IT = \&linux_size_check; + } } elsif (BSD_LIKE) { # will getrusage work on all BSDs? I should hope so. @@ -83,6 +87,23 @@ die "Apache2::SizeLimit not implemented on $^O"; } +} + +sub linux_smaps_size_check_first_time { + + if ($USE_SMAPS) { + $HOW_BIG_IS_IT = \&linux_smaps_size_check; + } else { + $HOW_BIG_IS_IT = \&linux_size_check; + } + + goto &$HOW_BIG_IS_IT; +} + +sub linux_smaps_size_check { + + my $s = Linux::Smaps->new($$)->all; + return ($s->size, $s->shared_cleani + $s->shared_dirty); } # return process size (in KB)