X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher.pm;h=fcb3aeaf16962bd8ff3dc07104bb8d40ad72c5bb;hb=e592e0bc4aaf7ce59e4d5eec9834cb430ab6a33f;hp=6b7cf630097091bd4dd34fb24586b45e2244f57b;hpb=0c1b51b8ad98f6b1739af1744a640bd1d1a86e1f;p=kivitendo-erp.git diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 6b7cf6300..fcb3aeaf1 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -18,6 +18,7 @@ use File::Basename; use IO::File; use List::MoreUtils qw(all); use List::Util qw(first); +use POSIX qw(setlocale); use SL::ArchiveZipFixes; use SL::Auth; use SL::Dispatcher::AuthHandler; @@ -51,6 +52,11 @@ sub new { SL::ArchiveZipFixes->apply_fixes; + # Initialize character type locale to be UTF-8 instead of C: + foreach my $locale (qw(de_DE.UTF-8 en_US.UTF-8)) { + last if setlocale('LC_CTYPE', $locale); + } + return $self; } @@ -225,7 +231,7 @@ sub handle_all_requests { while ($request->Accept() >= 0) { $self->handle_request($request); - $self->restart_after_request(1) if $self->_interface_is_fcgi && $self->_memory_usage_is_too_high; + $self->restart_after_request(1) if $self->_interface_is_fcgi && SL::System::Process::memory_usage_is_too_high(); $request->LastCall if $self->restart_after_request; } @@ -491,54 +497,6 @@ sub _check_for_old_config_files { end_request(); } -sub _parse_number_with_unit { - my ($number) = @_; - - return undef unless defined $number; - return $number unless $number =~ m{^ \s* (\d+) \s* ([kmg])b \s* $}xi; - - my %factors = (K => 1024, M => 1024 * 1024, G => 1024 * 1024 * 1024); - - return $1 * $factors{uc $2}; -} - -sub _memory_usage_is_too_high { - return undef unless $::lx_office_conf{system}; - - my %limits = ( - rss => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_rss}), - size => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_vsz}), - ); - - # $::lxdebug->dump(0, "limits", \%limits); - - return undef unless $limits{rss} || $limits{vsz}; - - my %usage; - - my $in = IO::File->new("/proc/$$/status", "r") or return undef; - - while (<$in>) { - chomp; - $usage{lc $1} = _parse_number_with_unit($2) if m{^ vm(rss|size): \s* (\d+ \s* [kmg]b) \s* $}ix; - } - - $in->close; - - # $::lxdebug->dump(0, "usage", \%usage); - - foreach my $type (keys %limits) { - next if !$limits{$type}; - next if $limits{$type} >= ($usage{$type} // 0); - - $::lxdebug->message(LXDebug::WARN(), "Exiting due to memory size limit reached for type '${type}': limit " . $limits{$type} . " bytes, usage " . $usage{$type} . " bytes"); - - return 1; - } - - return 0; -} - sub end_request { die SL::Dispatcher->END_OF_REQUEST; }