1

fix memcache pool complints, fix eval magic

This commit is contained in:
eleksir
2018-02-09 22:05:35 +03:00
parent d8a1e41eb2
commit 0d201b00ba

View File

@@ -6,13 +6,33 @@ use Cache::Memcached;
use URI::URL; use URI::URL;
my $HTINY = undef; my $HTINY = undef;
my $HTINYS = undef; my $HTINYS = undef;
$HTINY = eval {
eval {
require HTTP::Tiny; # stock perl module, but some assholes from debian rip perl into modules, require HTTP::Tiny; # stock perl module, but some assholes from debian rip perl into modules,
import HTTP::Tiny; # so there is non-zero possibility that we have no this module import HTTP::Tiny; # so there is non-zero possibility that we have no this module
$HTINYS = HTTP::Tiny->can_ssl; # to operate ssl stuff, we need Net::SSLeay, but sometimes
return 1; # installed perl environment lacks it, so use Tiny with care
}; };
if ($@ eq '') {
$HTINY = 1;
eval {
require Net::SSLeay;
import Net::SSLeay;
};
if ($@ eq '') {
eval {
require IO::Socket::SSL;
import IO::Socket::SSL;
};
if ($@ eq '') {
$HTINYS = 1; # to operate ssl stuff, we need Net::SSLeay, but sometimes
# installed perl environment lacks it, so use Tiny with care
}
}
}
my $IMAGEMAGICK = undef; # use on demand my $IMAGEMAGICK = undef; # use on demand
if ($^O ne 'cygwin') { # cygwin 2.882 64-bit has broken Image::Magick if ($^O ne 'cygwin') { # cygwin 2.882 64-bit has broken Image::Magick
$IMAGEMAGICK = eval { $IMAGEMAGICK = eval {
@@ -41,7 +61,7 @@ while ( 1 ) {
my $memd = new Cache::Memcached { 'servers' => [ "127.0.0.1:11211" ] }; my $memd = new Cache::Memcached { 'servers' => [ "127.0.0.1:11211" ] };
my $itemref = $memd->stats(['items']); my $itemref = $memd->stats(['items']);
if (length($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) > 2) { if (defined($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) and (length($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) > 2)) {
my $slabinfo = (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}))[0]; my $slabinfo = (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}))[0];
my $slab = (split(/\:/, $slabinfo))[1]; my $slab = (split(/\:/, $slabinfo))[1];
my $itemsamount = (split(/ /, $slabinfo))[2]; my $itemsamount = (split(/ /, $slabinfo))[2];