diff -Nru apt-cacher-1.7.24/apt-cacher apt-cacher-1.7.25/apt-cacher --- apt-cacher-1.7.24/apt-cacher 2021-12-21 17:37:19.000000000 +0000 +++ apt-cacher-1.7.25/apt-cacher 2022-01-16 16:10:47.000000000 +0000 @@ -1640,28 +1640,33 @@ sub cache_size { use File::Find qw(); - use IPC::Shareable qw(); + use IPC::ShareLite qw(); use IPC::SysV qw(); - tie my %du, 'IPC::Shareable', { key => IPC::SysV::ftok($cfg->{'cache_dir'}, 1), - mode => oct(600), - create => 1} || info_message("Warning: failed to tie hash: $1"); + my $shm = IPC::ShareLite->new( + -key => IPC::SysV::ftok($cfg->{'cache_dir'}, 2), + -mode => oct(600), + -create => 1, + -destroy => 0 + ) or die $!; + + my ($total, $ts) = (0,0); + my $cached = $shm->fetch(); + ($total, $ts) = split('@', $cached) if $cached =~ m/^\d+@\d+$/; # Sliding scale from 0 to 20 seconds - if (($du{'last_time'}||0) + - (20 * ($cfg->{'_disk_usage_limit'} - ($du{'size'}||0)) / $cfg->{'_disk_usage_limit'}) < - (my $time = time) and - (tied %du)->shlock(LOCK_EX|LOCK_NB)) { - $du{'size'}=0; + if (($ts + (20 * ($cfg->{'_disk_usage_limit'} - $total) / $cfg->{'_disk_usage_limit'})) < ($ts = time) and + $shm->lock(LOCK_EX | LOCK_NB)) { + $total = 0; File::Find::find({ - wanted => sub { $du{'size'} += -f $_ ? -s _ : 0 }, + wanted => sub { $total += -f $_ ? -s _ : 0 }, preprocess => sub { grep {-r} @_ } # skip non-readable - }, $cfg->{'cache_dir'}); - $du{'last_time'} = $time; - (tied %du)->shunlock; - debug_message("Cache Size: $du{'size'}"); + }, $cfg->{'cache_dir'}); + debug_message("Cache Size: $total"); + $shm->store(join('@', $total, $ts)); + $shm->lock(LOCK_UN) } - return $du{'size'}; + return $total; } sub loadavg { diff -Nru apt-cacher-1.7.24/debian/changelog apt-cacher-1.7.25/debian/changelog --- apt-cacher-1.7.24/debian/changelog 2021-12-21 17:37:19.000000000 +0000 +++ apt-cacher-1.7.25/debian/changelog 2022-01-16 16:10:47.000000000 +0000 @@ -1,3 +1,9 @@ +apt-cacher (1.7.25) unstable; urgency=medium + + * Change to use IPC::ShareLite. + + -- Mark Hindley Sun, 16 Jan 2022 16:10:47 +0000 + apt-cacher (1.7.24) unstable; urgency=medium [ Debian Janitor ] diff -Nru apt-cacher-1.7.24/debian/control apt-cacher-1.7.25/debian/control --- apt-cacher-1.7.24/debian/control 2021-12-21 17:37:19.000000000 +0000 +++ apt-cacher-1.7.25/debian/control 2022-01-16 16:10:47.000000000 +0000 @@ -12,7 +12,7 @@ Package: apt-cacher Architecture: all Pre-Depends: ${misc:Pre-Depends} -Depends: ${perl:Depends}, ${misc:Depends}, libwww-curl-perl, libwww-perl, ed, libio-interface-perl, libio-interactive-perl, libfilesys-df-perl, libnetaddr-ip-perl, lsb-base (>= 3.2-14), update-inetd, libsys-syscall-perl, libipc-shareable-perl, libdpkg-perl +Depends: ${perl:Depends}, ${misc:Depends}, libwww-curl-perl, libwww-perl, ed, libio-interface-perl, libio-interactive-perl, libfilesys-df-perl, libnetaddr-ip-perl, lsb-base (>= 3.2-14), update-inetd, libsys-syscall-perl, libipc-sharelite-perl, libdpkg-perl Recommends: libberkeleydb-perl, libio-compress-lzma-perl Suggests: libio-socket-inet6-perl, libfreezethaw-perl Description: Caching proxy server for Debian/Ubuntu/Devuan software repositories